【问题标题】:Mail generated using PHP mail function showing only code使用 PHP 邮件函数生成的邮件仅显示代码
【发布时间】:2014-09-15 06:53:23
【问题描述】:

我已经编写了一个使用 PHP mail() 函数发送邮件的代码

    $message = "
            <html>
            <head>
            <title>TITLE</title>
            </head>
            <body>
            <p>Customer ".$customerName." with id ".$customerId." wishes to place order for the following products that are currently note available in stock</p>
            <table>
            <tr>
            <th align='center'>Product Name</th>
            <th align='center'>Product Id</th>
            <th align='center'>Product Part Number</th>
            <th align='center'>Quantity</th>

            </tr>"
            .$content.

            "

            </table>
            </body>
            </html>
";


$headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    // More headers
     $headers .= 'From: '.$customerEmail.'' . "\r\n";


    mail($to,$subject,$message,$headers);

邮件对我来说工作正常,但对于客户来说,它看起来像这样

From:
Sent: None
To: orders@xxxxx.com
Subject: SUBJECT

Content-type:text/html;charset=UTF-8

From: xxxx@xxxx.com
Message-Id: <20140908144611.165ACC36BC@SV08.xxxxxx.com>
Date: Mon,  8 Sep 2014 17:46:11 +0300 (AST)
X-Nonspam: None
X-Antivirus: avast! (VPS xxx-0, 09/09/2014), Inbound message
X-Antivirus-Status: Clean


            <html>
            <head>
            <title>TITLE</title>
            </head>
            <body>


    <p>Customer XXXX with id 3
wishes to place order for the following products that are currently not
available in stock</p>
                <table>
                <tr>
                <th align='center'>Product Name</th>
                <th align='center'>Product Id</th>
                <th align='center'>Product Part Number</th>
                <th align='center'>Quantity</th>



    </tr><tr><td
align='center'>SCREW;BHHS;3/8-16 X .75</td><td align='center'>3237<td
align='center'>35059</td><td align='center'>6</td></tr>

            </table>
            </body>
            </html>

我不明白为什么它对我们的测试有效,但对客户无效。我使用我的 gmail 帐户进行了测试,当客户在其公司域上使用他的邮件 ID 时,它显示良好。

【问题讨论】:

  • 我感觉,设置的问题可能是客户端没有启用邮件的html内容
  • 只需重启你的测试服务器
  • 如何为客户端 Ram sharma 启用 html 内容??
  • 我觉得你需要把双引号(")换成单引号(')...

标签: php html email magento


【解决方案1】:

我建议您使用带有 google mail smtp 凭据的 phpMailer 库,而不是 php 邮件功能。这将帮助您发送 HTML 模板邮件。

参考网址 - PHP mailer example url

【讨论】:

    【解决方案2】:

    使用以下标题行

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    

    【讨论】:

      【解决方案3】:

      从您的 $message 中删除和标记。并将标题更改为

      $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
      $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
      $headers .= "CC: susan@example.com\r\n";
      $headers .= "MIME-Version: 1.0\r\n";
      $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
      

      【讨论】:

        猜你喜欢
        • 2020-08-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-15
        • 2011-12-25
        • 1970-01-01
        • 2012-06-27
        • 2013-03-17
        相关资源
        最近更新 更多