【问题标题】:Set variable to be formatted in HTML before sending email在发送电子邮件之前将变量设置为 HTML 格式
【发布时间】:2010-10-01 05:47:14
【问题描述】:

我正在发送一封电子邮件,邮件 ($message) 是 HTML 格式

我之前使用了不同的脚本(HTML MIME MAIL),我只是通过执行以下操作将其设置为 HTML:setHTML($message)。

使用此脚本,我不确定如何将 $message 设置为在电子邮件中输出为 HTML。

require_once "Mail.php";

$from = "noreply@domain.com";
$host = "mail.domain.com";
$username = "username";
$password = "password";

$headers = array ('From' => $from,
'To' => $emailto,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($emailto, $headers, $message);

if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
} else {
    echo("<p>Message successfully sent!</p>");
}

【问题讨论】:

    标签: php html email


    【解决方案1】:

    你错过了说它是 html 的标题,试试这个:

    $headers = array ('From' => $from,
    'To' => $emailto,
    'Subject' => $subject,
    'MIME-Version' => '1.0',
    'Content-type' => 'text/html; charset=iso-8859-1');
    

    【讨论】:

      猜你喜欢
      • 2010-11-26
      • 2014-06-22
      • 1970-01-01
      • 2013-11-08
      • 2015-03-20
      • 2011-06-01
      相关资源
      最近更新 更多