【发布时间】:2015-05-01 16:25:16
【问题描述】:
电子邮件已成功发送,但我想发送电子邮件以包含页脚 html 模板,因此我添加了以下几行:
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8 \r\n";
现在没有发送电子邮件。我该如何解决?
$emails = array("test@gmail.com");
$emails = array_unique($emails);
$subject = $_POST['subject'];
$message = $_POST['message'];
$message.="<div class='footer'>
<ul style='padding: 0;margin: 0;'>
<li><img style='width:300px' src='https://www.test.co.uk/wp-content/themes/test/images/structural/head-logo.jpg' /></li>
<li style='list-style-type: none;margin-bottom:6px;'><span style='color: #73a724;font-weight: bold;'>Tel:</span> +44 203 051 1214</li>
<li style='list-style-type: none;margin-bottom:6px;'><span style='color: #73a724;font-weight: bold;'>Fax:</span> +44 207 657 3322</li>
<li style='list-style-type: none;margin-bottom:6px;'><span style='color: #73a724;font-weight: bold;'>E-mail:</span> info@test.co.uk </li>
<li style='list-style-type: none;margin-bottom:6px;'><span style='color: #73a724;font-weight: bold;'>Web:</span> www.test.co.uk</li>
</ul>
</div>";
$headers = 'From: test <info@test.co.uk>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8 \r\n";
$success = wp_mail( $emails, $subject, $message, $headers ); //send emails
【问题讨论】:
-
WordPress 只是将这些东西传递给 PHP 的默认函数。尝试将标头的 from 部分放在 mime 和内容类型之后。
-
试过但还是没用.. 仅当我删除 mime/content-type 时才有效
-
查看您服务器上的邮件日志,看看是否有任何错误。
标签: wordpress