Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...