Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 带有PHPMailer的SMTP gmail_Email_Smtp_Phpmailer - Fatal编程技术网

Email 带有PHPMailer的SMTP gmail

Email 带有PHPMailer的SMTP gmail,email,smtp,phpmailer,Email,Smtp,Phpmailer,我对PHPMailer有问题。上个月我用同样的剧本做了,效果很好 代码如下: $alemail = 'anotherof@yahoo.com'; //send email $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPDebug = 2; $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'someof@my

我对PHPMailer有问题。上个月我用同样的剧本做了,效果很好

代码如下:

$alemail = 'anotherof@yahoo.com';

//send email

$mail = new PHPMailer;

$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'someof@mydomain.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('someof@mydomain.com', 'my name');
$mail->addReplyTo('someof@mydomain.com', 'my name');
$mail->addAddress($alemail);
$mail->isHTML(true);
$mail->Subject = 'test';
$mail->Body    = 'hello test';

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
错误是: 2015-02-04 09:01:01 SMTP错误:无法连接到服务器:无法访问网络(101)2015-02-04 09:01:01 SMTP connect()失败。邮件未发送。邮件程序错误:SMTP connect()失败

我已经和我的服务器提供商联系过了,他们说他们的服务器端没有问题

我也已经在谷歌应用程序上做了SMTP中继设置,但仍然不起作用

有什么建议吗


提前感谢您的更新。。我几天前已经解决了这个问题

显然这是服务器的问题。但当我询问我的服务器提供商时,他们声称基于telnet结果检查的服务器smtp连接没有问题:

Trying 64.233.169.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP m65sm1615043oif.5 - gsmtp
^]
所以我要求他们将我的文件重新定位到其他服务器上,现在PHPMailer脚本工作得很好


感谢@Synchro的回复。

就像上面说的那样-您的网络无法访问。您可以尝试设置
SMTPDebug=4
,以获取有关连接的详细信息。可能也有用。我尝试了'code'SMTPDebug=4,但出现了以下错误:2015-02-04 13:19:59连接:打开smtp.gmail.com:587,t=300,opt=array()2015-02-04 13:20:41 smtp错误:无法连接到服务器:网络无法访问(101)2015-02-04 13:20:41 smtp连接()失败。邮件未发送。邮件程序错误:SMTP connect()失败。。。不知道。。我的意思是,它曾经是工作的……好吧,所以这里没有什么新东西——试试指南中提到的所有其他东西。@Synchro仍然没有进展。。因此,该错误也不是来自PHPMailer和我的服务器提供程序(基于他们在指南中的测试)。。那么错误来自哪里呢?谢谢你的回复