我知道这个主题到处都有很多信息,但我似乎是在圈子里走来走去,非常感谢任何帮助。我正在尝试发送一个带有内联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);
?>
答案 0 :(得分:0)
尝试添加:
$headers .= "From: $from" . "\r\n" .
"Reply-To: $from" . "\r\n" .
'X-Mailer: PHP/' . phpversion();
答案 1 :(得分:0)
重写此代码:
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
到此:
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "To: ". $to. "\r\n";
$headers .= "From: ". $from;