php - GMail Username and Password not accepted error when sending email with SwiftMailer -


i following error when trying use gmail account send email php application swiftmailer.

535-5.7.8 username , password not accepted 

this swiftmailer code:

$transporter = swift_smtptransport::newinstance('smtp.gmail.com', 465, 'ssl')     ->setusername('ayrshireminiscontact@gmail.com')     ->setpassword('~password-in-here~');  $mailer  = swift_mailer::newinstance($transporter); $message = swift_message::newinstance('portfolio enquiry')     ->setfrom(array('ayrshireminiscontact@gmail.com' => 'crmpicco portfolio enquiry'))     ->setto(array('picco@crmpicco.co.uk' => 'a name'))     ->setbody($email_body);  $result = $mailer->send($message); 

this entry in apache error log , stack trace.

[wed aug 18 22:06:10.284728 2015] [:error] [pid 9298] [client 10.0.0.1:64806] php fatal error: uncaught exception 'swift_transportexception' message 'expected response code 250 got code "535", message "535-5.7.8 username , password not accepted. learn more at\r\n535 5.7.8 https://support.google.com/mail/answer/14257 gj13sm2191931wic.22 - gsmtp\r\n"' in /var/www/portfolio/swiftmailer/lib/classes/swift/transport/abstractsmtptransport.php:383\nstack trace:\n#0 /var/www/portfolio/swiftmailer/lib/classes/swift/transport/abstractsmtptransport.php(281): swift_transport_abstractsmtptransport->_assertresponsecode('535-5.7.8 usern...', array)\n#1 /var/www/portfolio/swiftmailer/lib/classes/swift/transport/esmtptransport.php(243): swift_transport_abstractsmtptransport->executecommand('rset\r\n', array, array)\n#2 /var/www/portfolio/swiftmailer/lib/classes/swift/transport/esmtp/auth/xoauth2authenticator.php(54): swift_transport_esmtptransport->executecommand('rset\r\n', array)\n#3 /var/www/portfolio/swiftmailer/lib/classes/swift/transport/esmtp/authhandler.php(176): swift_transport_esmtp_auth_xoauth2authent in /var/www/portfolio/swiftmailer/lib/classes/swift/transport/abstractsmtptransport.php on line 383, referer: https://crmpicco.dev/

i have tried http://www.google.com/accounts/displayunlockcaptcha , can log in account through web browser without problems.

this happens on local development machine , publically-accesible site. issue gmail account or implementation?

you need allow access less-secure apps, because imap via password fundamentally insecure. (it's non-revocable)

better yet, switch oauth authentication.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -