Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

php - PHPMailer Gmail Server Error

I'm having a little trouble with PHPMailer. Can someone help? Please don't tell me my username and password might be wrong. I triple-checked and they are correct.

The lines of code that I think could be the issue are:

$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = '*********@gmail.com';
$mail->Password = '*********';
$mail->setFrom('*********@gmail.com','Name');

The error log output is:

2015-12-31 16:46:17 CLIENT -> SERVER: EHLO nfective.com
2015-12-31 16:46:17 CLIENT -> SERVER: STARTTLS
2015-12-31 16:46:17 CLIENT -> SERVER: EHLO nfective.com
2015-12-31 16:46:17 CLIENT -> SERVER: AUTH LOGIN
2015-12-31 16:46:17 CLIENT -> SERVER: bmZlY3RpdmVAZ21haWwuY29t
2015-12-31 16:46:17 CLIENT -> SERVER: JCNAZDB3MTM=
2015-12-31 16:46:17 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 w32sm33173561qgw.6 - gsmtp 2015-12-31 16:46:17 SMTP Error: Could not authenticate. 2015-12-31 16:46:17 CLIENT -> SERVER: QUIT 2015-12-31 16:46:17 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting bool(false)

It could also be GMail's authentication is beyond the capabilities of PHPMailer. I'm not sure.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into this SO many times. Gmail is finicky. You need to do some things on your end to make this work.

Follow the instructions here: https://support.google.com/mail/answer/14257?rd=1

You'll also need to be logged into your gmail account and go here: https://accounts.google.com/b/0/DisplayUnlockCaptcha

You'll also have to allow less secure apps to sign into your gmail account, under security settings on your account you'll have to push that button to allow.

Good luck! After you make the adjustments and double triple check you have everything in order and your password is correct, you may have to wait a second. It's really annoying! But once it's working you can rely on it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...