yiisoft / yii2-swiftmailer

Yii 2 swiftmailer extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
116 stars 74 forks source link

Doesn't appear to work with Gmail #34

Closed starrychloe closed 8 years ago

starrychloe commented 8 years ago

What steps will reproduce the problem?

http://stackoverflow.com/questions/37290204/cannot-send-email-from-yii-swiftmail-to-gmail-expected-response-code-250-but-go/37290443

    'smtp.host' => 'smtp.gmail.com',
    'smtp.username' => 'contact@xxxxxxxxxx.com',
    'smtp.password.encrypted' => 'xxxxxxxxxxx',
    'smtp.port' => '587',
    'smtp.encryption' => 'tls',

What's expected?

Expect the email to send.

What do you get instead?

Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257

Additional info

Q A
Yii vesion 2.0.7
PHP version PHP 5.6.19
Operating system Windows 8.1
klimov-paul commented 8 years ago

Are you able to send your message successfully using plain SwiftMailter without Yii being involved?

starrychloe commented 8 years ago

No, it doesn't seem to work.

<?php
// echo phpinfo();

require_once 'vendor/swiftmailer/swiftmailer/lib/swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587)
  ->setUsername('contact@bestsales.com')
  ->setPassword('xxx')
  ->setEncryption('tls');

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
  ->setTo(array('contact@bestsales.com'))
  ->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);
$ php web/test.php
PHP Fatal error:  Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 n77sm442213qhb.13 - gsmtp
klimov-paul commented 8 years ago

This is not Yii issue. You may open a ticket at swiftmailer project.