【问题标题】:HTML email through SES SMTP interface - PEAR通过 SES SMTP 接口的 HTML 电子邮件 - PEAR
【发布时间】:2016-09-30 07:04:52
【问题描述】:

我希望发送 HTML 电子邮件。我尝试使用mime.php,但无法正常工作。以下是我的工作文本电子邮件代码:

<?php
$subject="hello-test";
$body="<html><body><h1>message body</h1></body></html>";

$em_arr=array("email@example.com");
foreach ($em_arr as $to_address)
{

require_once '/usr/local/share/pear/Mail.php';

$headers = array (
  'Content-Type:text/html;charset=UTF-8',
  'From' => 'Test <test@example.com>',
  'To' => $to_address,
  'Subject' => $subject);

$smtpParams = array (
  'host' => '<smtp host address>',
  'port' => 587,
  'auth' => true,
  'username' => '<uname>',
  'password' => '<password>'
);

 // Create an SMTP client.
$mail = Mail::factory('smtp', $smtpParams);

// Send the email.
$result = $mail->send($to_address, $headers, $body);

if (PEAR::isError($result)) {
  echo("Email not sent. " .$result->getMessage() ."\n");
} else {
  echo("Email sent to ".$to_address."\n");
}
}
?>

请告诉我如何发送 HTML 电子邮件。

【问题讨论】:

    标签: html-email pear amazon-ses


    【解决方案1】:

    我不得不将 Content 标题行替换为:

    'Content-Type' => "text/html; charset=UTF-8",
    

    这是上面的错误。现在工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 2018-10-12
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 2012-01-21
      • 2012-05-26
      相关资源
      最近更新 更多