PHPMailer不返回错误但不发送任何电子邮件(实时服务器) [英] PHPMailer returning no Error But Not Sending any Email(Live Server)

查看:393
本文介绍了PHPMailer不返回错误但不发送任何电子邮件(实时服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码:

<?php
require ('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
//$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'allthingsremainhere@gmail.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SetFrom('youcanreply@lishup.com', 'Reply It! - LishUp');
$mail->AddAddress('techgoeshere@gmail.com', 'Tech');
$mail->Subject  = 'First PHPMailer Message';
$mail->Body     = 'Hi! This is my first e-mail sent through PHPMailer.';

if(!$mail->send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
?>

它正在返回消息已发送".

It is returning 'Message has been Sent'.

我的电子邮件和密码没问题.那不是问题.

My Email and Password is alright. That's not the problem.

在Google帐户中:2Factor授权已关闭,并且允许安全程度较低的应用"已打开

我正在使用Google Cloud上托管的Live Server.请帮我解决这个问题

I am using a Live Server hosted on Google Cloud. Please help me to solve this

推荐答案

首先,您使用的是旧版本的PHPMailer. 获取最新信息.

First of all, you're using an old version of PHPMailer. Get the latest.

几乎所有的代码都没有执行任何操作,因为您注释了isSMTP().这意味着PHPMailer将通过PHP的mail()函数发送,并且不会使用与SMTP相关的任何设置.结果,您的消息将不会通过gmail发送,而是通过您的本地邮件服务器发送,该服务器将默默地接受您提供的任何内容,但之后将无法继续转发.如果您的发送域使用的是gmail,则很可能您将无法通过SPF检查,并且您的消息将永远无法传递.

Almost none of your code does anything because you commented out isSMTP(). That means that PHPMailer will send via PHP's mail() function, and none of your SMTP-related settings will be used. As a result, your message will not be sent through gmail, but via your local mail server instead, which will be silently accepting whatever you give it but then failing to relay it any further. If your sending domain is using gmail, it's likely that you will fail SPF checks, and your messages will never be delivered.

通过阅读本地邮件服务器的日志文件(可能在/var/log/mail.log之类的地方),您可以准确地看到邮件发生了什么情况.

You can see exactly what has happened to your messages by reading your local mail server's log file, probably somewhere like /var/log/mail.log.

这篇关于PHPMailer不返回错误但不发送任何电子邮件(实时服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆