【发布时间】:2015-03-19 18:06:11
【问题描述】:
我知道到处都有很多关于这个主题的信息,但我似乎在兜圈子,非常感谢任何帮助。我正在尝试发送带有一些内联 css 的简单 html 电子邮件。电子邮件似乎没有到达...
<?php
// Email the user their activation link
$to = "name@website.com";
$from = "me@website.com";
$subject = 'Test HTML Email';
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<div style="padding:10px; background:#000; font-size:46px; font-weight: 900; color:#fff; ">
My Website
</div>
<div style="padding:24px; font-size:17px; background:#DCDCDC ; ">
This is a message sent from my website
<br>
<br>
<a href="http://www.mywebsite.com">Login in to your account</a>
<br>
<br>
</div>';
mail($to, $subject, $message, $headers);
?>
【问题讨论】:
-
试试:$isMailed = mail($to, $subject, $message, $headers);回声 $isMailed;这是返回真还是假?并添加 $headers .= "From: yourmail.com \r\n";刚看到,但是本在我前面..
-
发件人未定义。
-
我倾向于建议不要使用
mail(),而只是使用一个像样的库(PHPMailer、SwiftMailer)。这也可以防止安全问题,例如标头注入。