smtp的Gmail邮件服务器的PHP邮件工作不正常 [英] smtp gmail server php mailer not working

查看:161
本文介绍了smtp的Gmail邮件服务器的PHP邮件工作不正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题之前已经被问过很多次了。但解决方案似乎没有帮助我。因此,我发布了我的代码:

 <?php 
require(class.phpmailer.php) ;
require(class.smtp.php);
$ mail = new PHPMailer();
$ mail-> IsSMTP();
$ mail-> Host =smtp.gmail.com;
$ mail-> SMTPDebug = 1;
$ mail-> SMTPAuth = true;
$ mail-> SMTPSecure =ssl;
$ mail->端口= 465;
$ mail->用户名=me@gmail.com;
$ mail->密码=mypassword;
$ mail-> AddAddress(to@yahoo.co.in);
$ mail-> SetFrom(me@gmail.com,myname);
$ mail-> AddReplyTo(someone@gmail.com,someone);
$ mail-> Subject =来自我的问候;
$ mail->身体=问候!!我很高兴你收到此消息;
$ mail-> WordWrap = 50;
if($ mail-> send())
{
echoMail sent successfully;
}
else
{
echo抱歉的邮件无法发送,因为错误$ mail-> ErrorInfo;
}
?>

SMTP调试是:

  CLIENT  - >服务器:EHLO messengerclick.byethost3.com 2015-07-26 12:49:42 CLIENT  - >服务器:AUTH LOGIN 2015-07-26 12:49:42 
CLIENT - >服务器:Y2hlcm9ja3oxOUBnbWFpbC5jb20 = 2015-07-26 12:49:42
客户端 - >服务器:Y2hldGFucm9ja3MxOQ == 2015-07-26 12:49:43
SMTP错误:密码命令失败:534-5.7.14请通过您的网络浏览器和534-5.7.14登录,然后重试。 534-5.7.14了解更多信息534 5.7.14 https://support.google.com/mail/answer/78754 sc16sm22415466wjb.28 - gsmtp 2015-07-26 12:49:43
SMTP错误:可以不认证。 2015-07-26 12:49:43
客户 - > SERVER:QUIT 2015-07-26 12:49:43 SMTP连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting由于错误SMTP connect()失败,抱歉的邮件无法发送。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我启用了访问未知我的Gmail帐户上的应用程序。
我也点击了此链接继续
http://www.google。 com / accounts / DisplayUnlockCaptcha
登录后。
我从我的byethost帐户运行此操作。这是工作正常smtp.mail.yahoo.com



请帮助我知道我做错了什么。

解决方案

如果您确定自己的密码正确,可以尝试以下问题排查提示:



  • 如果您为自己的帐户启用了两步验证功能,则可能需要输入应用程序密码。 通过网络登录您的帐户 https://mail.google.com 上的Gmail版本。之后,再次尝试在
    您的邮件应用中访问您的邮件。

  • 如果您仍然遇到问题,请访问 http://www.google.com/accounts/DisplayUnlockCaptcha 并使用
    登录您的Gmail用户名和密码。如有必要,请在
    中输入扭曲图片中的字母。

  • 您的邮件应用可能不支持最新的安全标准。了解如何让安全性较低的应用访问您的帐户。

  • 确保您的邮件应用未设置为频繁检查新邮件。如果您的邮件应用程序每10分钟检查一次新邮件
    以上,则应用程序对您帐户的访问权限可能会被阻止。

  • 尝试根据我们的创建提示更改密码一个强大的密码。


来源

这里,您可以允许安全性较低的应用程序。点击打开以允许安全性较低的应用拥有您的用户名和密码。


I know this question has been asked many a times before. But the solutions didn't seem to help me . So hereby I am posting my code:

<?php
require("class.phpmailer.php");
require("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->Host="smtp.gmail.com";
$mail->SMTPDebug=1; 
$mail->SMTPAuth=true;
$mail->SMTPSecure="ssl";
$mail->Port=465;  
$mail->Username ="me@gmail.com";
$mail->Password="mypassword";
$mail->AddAddress("to@yahoo.co.in");
$mail->SetFrom("me@gmail.com", "myname");
$mail->AddReplyTo("someone@gmail.com","someone");
$mail->Subject="Greetings from ME";
$mail->Body="Greeting !! I am glad you received this message";
$mail->WordWrap=50;
if($mail->send())
{
echo "Mail sent successfully";
}
else
{
echo "Sorry mail could not be sent because of error ".$mail->ErrorInfo;
}
?>

The SMTP Debug is:

CLIENT -> SERVER: EHLO messengerclick.byethost3.com 2015-07-26 12:49:42 CLIENT -> SERVER: AUTH LOGIN 2015-07-26 12:49:42    
CLIENT -> SERVER: Y2hlcm9ja3oxOUBnbWFpbC5jb20= 2015-07-26 12:49:42  
CLIENT -> SERVER: Y2hldGFucm9ja3MxOQ== 2015-07-26 12:49:43  
SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 sc16sm22415466wjb.28 - gsmtp 2015-07-26 12:49:43 
SMTP Error: Could not authenticate. 2015-07-26 12:49:43 
CLIENT -> SERVER: QUIT 2015-07-26 12:49:43  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Sorry mail could not be sent because of error SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I have enabled access for unknown apps on my gmail account. I have also clicked on continue on this link http://www.google.com/accounts/DisplayUnlockCaptcha after signing in. I am running this from my byethost account. It is working fine for smtp.mail.yahoo.com

Please help me know what I am doing wrong.

解决方案

If you’re sure your password is correct, you can try these troubleshooting tips:

  • If you've turned on 2-Step Verification for your account, you might need to enter an App password.
  • Sign in to your account from the web version of Gmail at https://mail.google.com. Afterwards try accessing your messages in your mail app again.
  • If you're still having problems, visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password. If necessary, enter the letters in the distorted picture.
  • Your mail app might not support the latest security standards. Learn how to allow less secure apps access to your account.
  • Make sure your mail app isn't set to check for new email too frequently. If your mail app checks for new messages more than once every 10 minutes, the app’s access to your account could be blocked.
  • Try changing your password according to our tips on creating a strong password.

Source.

Here, you can allow less secure apps. Click on Turn On to allow less secure apps having your username and password.

这篇关于smtp的Gmail邮件服务器的PHP邮件工作不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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