本文介绍了使用php邮件功能防止发送的电子邮件被视为垃圾邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个 PHP 脚本来发送电子邮件.

I wrote a PHP script to send emails.

我的脚本是这样的:

$headers =  'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'From: [email protected]' . "
";

// Email Variables
$toUser  = "[email protected]"; // 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";
}

嗯,当然,我使用有效的电子邮件地址作为发件人和收件人.我确实收到了电子邮件,但它变成了垃圾邮件.所以我去谷歌研究.是因为我的标题"脚本问题吗?如果不是,那么什么会导致我的脚本发送垃圾邮件?有什么解决办法吗?

Well, of course I use a valid email address for sender and receiver. I did receive the email, but it goes to junk mail. So I went for google research. Is it because of my "header" script problem? If it isn't, then what could cause my script to send a junk mail? Any solution?

推荐答案

请试试这个:

$headers ="From:<$from>
";
$headers.="MIME-Version: 1.0
";
$headers.="Content-type: text/html; charset=iso 8859-1";

mail($to,$subject,$body,$headers,"-f$from");

这篇关于使用php邮件功能防止发送的电子邮件被视为垃圾邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:41