2

This is the error that throws me:

Swift_TransportException in AbstractSmtpTransport.php line 383: 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 px4sm26723732oec.7 - gsmtp "

I have enabled "Allow less secure app" in my account and i haven't enable 2-Step Verification. And yes i already did "Display Unlock Captcha" configuration too, and nothing's changed. Please somebody help me.

This is my .env code:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME="my mail"
MAIL_PASSWORD="my password"
MAIL_ENCRYPTION=tls

This is my mail.php code:

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => "my mail", 'name' => null],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('my password'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,
];
Valeria
  • 160
  • 1
  • 3
  • 12

3 Answers3

0

Are you working on the Homestead or on the Live Server.For both of them you could follow up my steps. You can use the Guzzle and MailGun to test whether Outgoing Email is being Sent in your Server. You have to Set a Few Steps of how to Integrate Guzzle and MailGun From this link: https://laravel.com/docs/5.1/mail. I too have got the Same Error First and I have Tested with this and now it is working for me fine. My .env file will look like this for Mail Section.

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525
MAIL_USERNAME="YOUR MAIL GUN USER NAME"
MAIL_PASSWORD="YOUR MAIL GUN PASSWORD"
MAIL_ENCRYPTION="YOUR NEEDED ENCRYPTION TYPE" (Eg. tls/ssl)
MAIL_FROM="FROM MAIL ID"
MAIL_NAME="YOUR NAME AS IN THE FROM MAIL ID"
MAILGUN_DOMAIN="YOUR MAIL GUN DOMAIN FOR THAT PROJECT"
MAILGUN_SECRET="YOUR MAIL GUN SECRET KEY"

Port: 2525 is for the Homestead and you may use 465/587 AS PER YOUR Encryption methods. Make sure your config.php file have the env() function for all the Inputs that you are giving in the .env

Naresh Kumar P
  • 4,127
  • 2
  • 16
  • 33
  • I am working on the homestead, in fact it worked before and sent the emails but then i lost the file mail.php and I had to reconfigure and it stopped working. The mail.php is like i wrote before and seems fine. Well i will try with changing the port and then with mailgun, thank you i will tell you if it works. – Valeria Jan 07 '16 at 04:56
  • Problem solved, first i don't put my mail in the username on the mail.php file and then throw me other error "Authentication required" and i go to this post http://stackoverflow.com/questions/32693528/expected-response-code-220-but-got-code-with-message-in-laravel and solve it. For future generations. :) – Valeria Jan 07 '16 at 05:57
0

Got same issue, In my case it takes old credential, not reading from .env file, so cleared cache and config using php artisan cmd, then runs fine.

php artisan config:clear
php artisan cache:clear
151291
  • 3,308
  • 7
  • 48
  • 81
0

I had pretty much same situation today --- difference is that I had my php/swiftmailer worked a few days ago, changed nothing to my G Suite account and php code, but not today. Tried a few methods I got from searching online and stackoverflow.com, not working. Finally the solution that worked is that go to G Suite Admin Console -> Security -> Basic Setting -> Less Secure Apps -> choose the third one: enforce access to less secure apps. After this, my sending mail php code works again. Hope it helps.

Tony Xu
  • 3,031
  • 4
  • 32
  • 43