我已将PHPMailer的代码放在我要发送邮件的文件中,但邮件未送达。我尝试了普通的mail()
方法,但两者都发送了消息但是没有传递消息。这可能是主机服务的问题吗?
include('PHPMailer-master/PHPMailerAutoload.php');
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('from@example.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress( $_POST['RequestedEmail'], 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("");
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
注意:php新手
答案 0 :(得分:0)
我尝试了php和phpmailer的mail()
本机函数。两人都表示已发送邮件并且已成功发送消息,但消息未送达。我问托管服务器上的技术人员,他们回复说垃圾邮件拦截器阻止了这些邮件。所以他们要求消息的内容和标题确认它是清楚的,并从spamer中解锁它。 :)