PHPMailer Lite 和 PHPMailer Lite GMAIL SMTP:电子邮件未发送到雅虎邮箱,如何调试?
我正在尝试使用 phpMailer 和 GMail SMTP 发送电子邮件。向其他 Gmail 帐户发送电子邮件效果很好,但向雅虎发送邮件却永远无法到达那里。我读到有关使用 ip 地址等进行调试的内容,但我在该领域不熟练?
这是代码:
$mail->Mailer='smtp';
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "__email__"; // GMAIL username
$mail->Password = "__pass__"; // GMAIL password
$mail->SMTPDebug = 2;
$a = md5(uniqid(rand(), true)); //create a unique validation code
//These are the variables for the email
$mail->AddAddress (trim($_POST['email']),trim($_POST['username'])); // this is the email address collected form the form
$mail->Subject = "Registration"; // Subject
$mail->Body = "Thank you for registering\n your security code is ".$a;
$mail->Send();
echo "check your email to complete registration";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
$mail->ClearAddresses();
更新:发现问题:我们的服务器已被雅虎列入黑名单(不是我的错) 这样就浪费了一天半的时间。
I am attempting to send emails using phpMailer and GMail SMTP. It works fine sending emails to other Gmail accounts but sending to Yahoo the mail never gets there. I read about debugging using ip addresses and such, but I am not skilled in that area?
here is the code:
$mail->Mailer='smtp';
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "__email__"; // GMAIL username
$mail->Password = "__pass__"; // GMAIL password
$mail->SMTPDebug = 2;
$a = md5(uniqid(rand(), true)); //create a unique validation code
//These are the variables for the email
$mail->AddAddress (trim($_POST['email']),trim($_POST['username'])); // this is the email address collected form the form
$mail->Subject = "Registration"; // Subject
$mail->Body = "Thank you for registering\n your security code is ".$a;
$mail->Send();
echo "check your email to complete registration";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
$mail->ClearAddresses();
update: Found the problem: Our server had been blacklisted by Yahoo (not my fault)
so that's a day-and-a-half wasted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您使用 Google App Engine 的电子邮件服务。它会为您完成所有繁重的工作。另外,因为 gmail 有发送限制,而应用程序引擎的发送限制要高得多。它还具有慷慨的免费配额(1000 个收件人/天)。
以下是从当前登录用户发送消息的示例,如果用户未登录,则使用 login_required 注释将用户重定向到登录页面:
Instead of gmail I would advise you to use Google App Engine's email service. It does all the heavy lifting for you. Also because gmail has a send limit while app engine's is much higher. It also has a generous free quota(1000 recipients/day.
Here's an example of sending a message from the current signed-in user, using the login_required annotation to redirect the user to the sign-in page if they are not signed in:
由于它与 Gmail 用户一起使用,我的客人可能会认为某些 phpMailer 无法正确发送您的用户名和密码。如果您未经过身份验证,gmail 服务器将不会接受中继电子邮件。
一个问题,为什么不使用自己的电子邮件服务器,这将有助于调试并了解电子邮件未发送的原因。
Since it's working with Gmail users my guest would be that some phpMailer is not sending your username and password properly. The gmail server won't accept to relay email if you are not authenticated.
One question, why don't you use your own email server, it would help to debug and to know why the emails are not sent.