New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google XOAUTH2 authentication fails #543
Comments
This might be related to #539, so try what's in the master branch at the moment. It seems that the league OAuth library changed its implementation and broke stuff. |
Incidentally you don't need to allow "less secure apps" if you're using XOAUTH2. If you have it enabled you can use regular ID and password auth, which should do as a workaround until this issue is sorted out. |
I have also experienced those broken stuff that people reported there, but I think I could fix them, while I finally got the token. Or it can be wrong this way? |
First I had tried just that simple way without XOAUTH2 and with username and password, but got the same error. I have also tried it again after I enabled less secure apps, but same error. But god, I will try it again just to be sure. |
Not much success again.
|
Have you tried setting $mail->SMTPDebug = 4; I did that to get more verbose output I linked before.
My issue might be related to my webserver using Exim as the Message Transfer Agent. I contacted my ServerHost and they said "We do not redirect any traffic nor prevent any outbound connections from our network." You seem to at least by attempting to authenticate and getting the correct responses from google. Are you sure you got a refresh token and not a normal token? I have gone through all the troubleshooting on my side and as far as I can tell I am connecting to 'a google server'. I have no idea why oauth2 is not available. I am in random RnD mode trying to troubleshoot it. If I get any progress on it I will update you all in this ticket. |
Yeah, my webserver has no problem, I get to authentication every time, but it always fails. Login data is right, I can log in via browser. And yes, I've got both refresh and normal token, but I don't know how can I check if they are right or usable. I tried with SMTPDebug = 4 as you adviced and here what I get (before this everything works well):
When I try do the simple way without OAUTH2, I get this below. Maybe the auth type is not right for the simple username-pass authentication?
Google also advices app password. Can it help in my case? |
I've just check the Gmail inbox for this account, and I saw that when I had tried to send the message without OAUTH2 and got the result above, a mail delivery notification arrived, that the delivery for that mail is failed. What the hell is going on? I feel quite desperate now... |
Like the troubleshooting docs say, you can enable access for "less secure apps" and use normal id and password auth. Unfortunately OAuth is extremely difficult to debug, just one of its many failings. |
It's enabled, as I said still in my first post. That's why I don't understand why it is still not working. As you can see in the last debug, the authentication fails even if I use the normal user-pass way, but it sends mail delivery notification about the failure, while it didn't happen before. |
Have you looked at all the things on that gmail support page? Quite a few of them could cause this behaviour, not just auth. |
I've checked every parameter once again then tried to send a message. Now the debugger says this:
So it seems that now it works, but somehow the recipient still doesn't get the mail, only the sender receives a delivery failure notification. Well, at least it works somehow. I'm still looking forward for a solution to OAUTH2, if there is any. |
So what does the notification say? It should give a reason for the bounce. XOAUTH2 only has an effect on the initial submission, anything after that is nothing to do with the auth scheme (or PHPMailer come to that). |
It says: I think it's because of the e-mail got blacklisted or something like that. I have to check that and contact the owner. So it's no longer a PHPMailer issue, cause it does its job now. However, I have one more question. As you could see in my PHP in my first post, I have this at the end: if (!$mail->send()) {
echo $mail->ErrorInfo;
} else {
echo "1";
} If the mail sending is successful, then why do I see the ErrorInfo posted before? And why it echoes "1" also at the end? It should echo only "1" and go on, right? |
I can't see it echoing '1' at the end in any of your examples, only errors. ErrorInfo is not the same thing as debug output, if that's what you mean. |
Yes, I see now, sorry. I forgot to turn off the debugger, that's why I didn't see what I had to. I got blind from this many debugging. :) So, PHPMailer is working fine now without XOAUTH2 and with the simple username-pass verification. However, recipient still doesn't get the message, it returns to the sender, but it's not the script's fault. We haven't found solution for the original XOAUTH2 issue, but the workaround works, so you can close this issue if you think. Thanks for the help and replies. |
It may be that you were running into one of the other factors listed on that support page - e.g. trying to auth too often, so you might find that XOAUTH2 works now! |
I try to use PHPMailer to send mails through a Gmail account, but somehow I have no success for days now and I have no idea how to make it work.
But when I try to send a mail:
It goes well for a while, but then the authentication fails.
My PHP code:
The only strange thing that happend during the setup was that when I tried to fetch the token, I didn't get that option which is in the tutorial ("PHPMailer would like to: View and manage your mail") but
"PHPMailer would like to:
Know who you are on Google
View your email address
View your basic profile info"
I don't know if it causes the failures or something else, but I have no idea what more I can do...
Thanks in advance.
The text was updated successfully, but these errors were encountered: