1
require("class.phpmailer.php");

$mail = new PHPMailer()

$mail->From = "sender@gmail.com";
$mail->AddAddress("recipient@gmail.com");                 // name is optional
$mail->AddReplyTo("sender@gmail.com");

$mail->WordWrap = 50;                                    // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

我不知道我需要添加哪些标头,以发送电子邮件而不是垃圾邮件,我该如何使用它?

//$mail->IsSMTP(); // is this necessary?
//$mail->Host = "some host ip";  // what i need to write here?
//$mail->SMTPAuth = true;     // is this necessary to send email NOT as spam?
//$mail->Username = "test";  // and this?
//$mail->Password = "secret"; // and this?

一段时间谷歌搜索,我没有找到任何关于如何发送电子邮件而不是垃圾邮件的明确信息......有什么想法吗?

4

3 回答 3

1

不幸的是,您当前使用的邮件服务器过去可能一直在发送垃圾邮件。您是否使用共享托管计划?因为如果您是,则与您使用相同托管计划的其他网站可能会通过相同的邮件服务器发送垃圾邮件/可疑/垃圾邮件。要尝试避免此问题,您应该尝试不要使用欺骗的 FROM 标头。不幸的是,如果 Gmail 等已经识别出您使用的邮件服务器作为垃圾邮件的来源,那么这不太可能做任何事情。

于 2012-09-06T08:18:33.107 回答
0

我不确定,但请参阅下面的 URL,我认为这对您很有帮助。

如何防止通过 PHP mail() 发送的邮件进入垃圾邮件?

如何防止通过 PHP mail() 发送的邮件进入垃圾邮件?

于 2012-09-06T08:33:00.197 回答
0

Make sure the From header really matches e-mail address available on the server you're sending it from - spoofing From headers (sending from host.com but saying it's from abc@otherhost.com) raises your spam score.

Also - is the HTML page well-formed to prevent being marked as spam? For example, does it have an unsubscribe link? Or isn't the subject of that mail something like "free something for you"?

于 2012-09-06T08:20:26.987 回答