oauth 2.0 - PHPMailer SMTP Gmail authentification error -


i'm sending emails using phpmailer 5.2.10 next code:

function sendgmail($to,$subj,$body) {     $mail = new phpmailer(); // create new object     $mail->issmtp(); // enable smtp     $mail->smtpdebug = 1; // debugging: 1 = errors , messages, 2 = messages     $mail->smtpauth = true; // authentication enabled     $mail->smtpsecure = 'ssl'; // "ssl" secure transfer enabled required gmail     $mail->host = "smtp.gmail.com";     $mail->port = 465; // 465 or 587     $mail->ishtml(true);     $mail->username = "admin@mydomain.ru";     $mail->password = "********";     $mail->setfrom("admin@mydomain.ru");     $mail->subject = $subj;     $mail->body = $body;     $mail->addaddress($to);     return $mail->send(); } 

note: use google apps, mail domain not google.com, other, let's say, mydomain.ru.

everything fine until google had implemented "security enhancement" (afaik forcing oauth2 authorisation). phpmailer->send() returns following text:

2015-05-12 06:49:15 client -> server: ehlo 127.0.0.1  2015-05-12 06:49:15 client -> server: auth login  2015-05-12 06:49:15 client -> server: [some base64 string]  2015-05-12 06:49:15 client -> server: [some base64 string]  2015-05-12 06:49:16 smtp error: password command failed: 535-5.7.8 username , password not accepted. learn more @ 535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 u10sm3566045lbb.30 - gsmtp  2015-05-12 06:49:16 smtp error: not authenticate.  2015-05-12 06:49:16 client -> server: quit  2015-05-12 06:49:16 smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting bool(false) done! 

ok, go http://support.google.com/mail/bin/answer.py?answer=14257 , doing following:

"access less secure apps: * turn off / * turn on" - normal gmail account,

("this setting inaccessible google apps accounts") - google apps account (not exact text translation russian google shows it).

yes, have tried both ssl , tls, 485 or 587 ports , else i've found on stackoverflow.com , here: https://github.com/phpmailer/phpmailer/wiki/troubleshooting . nothing helped.

phpmailer troubleshooting page suggests use "an oauth2 client class": http://www.phpclasses.org/package/7700-php-authorize-and-access-apis-using-oauth.html - have no idea of how integrate phpmailer , why it's not integrated yet phpmailer developers (this class under bsd license), while it's necessary 1 of popular mail servers. found no documentation oauth2 integrating phpmailer, , i'm sure can't myself - php knowledge poor.

the question is:

  1. how can avoid goddamn oauth2 , send emails did before "security enhancement" (for google apps account)? --or:

  2. how integrate oauth2 class mentioned above phpmailer? --or:

  3. are there other easy-to-use php solutions send emails using gmail?

lots of in advance.

thank reading docs, it's appreciated! problem google has imposed complicated authentication mechanism without regard users, have experienced. doesn't improve security because still have submit username , password on ssl token. oauth authorisation (what can do) protocol, google using indirectly authentication (who are) protocol.

the reason nobody has implemented while it's clever, oauth unpleasant , confusing work with, why we'd happy if got around implementing it!

this article helpful , might form basis of phpmailer implementation. though adds dependency on zf2, principles same other oauth implementation such 1 phpclasses linked or this one.

sorry can't more on this.

update: phpmailer supports oauth gmail. this article describes how use it, , yes still quite unpleasant!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -