我写了一个 PHP 脚本来发送电子邮件。
我的脚本是这样的:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: abc@yahoo.com' . "\r\n";
// Email Variables
$toUser = "someone@yahoo.com"; // recipient
$subject = "testing"; // subject
$body = "<html><body><p>
Example of including an image via html \<img\> tag:
<br>
<img src='../images/profile.jpg'>
<br>
My new picture
<br></p></body></html>"; // content
if (mail($toUser,$subject,$body,$headers)) {
echo "sent";
} else {
echo "failed";
}
好吧,我当然会为发件人和收件人使用有效的电子邮件地址。我确实收到了电子邮件,但它转到了垃圾邮件。所以我去谷歌研究。是因为我的“标题”脚本问题吗?如果不是,那么什么会导致我的脚本发送垃圾邮件?有什么解决办法吗?
最佳答案
请试试这个:
$headers ="From:<$from>\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-type: text/html; charset=iso 8859-1";
mail($to,$subject,$body,$headers,"-f$from");
关于php - 使用php邮件功能防止发送的电子邮件被视为垃圾邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/746809/