8

When I try to send an e-mail through my website running Laravel 4, I get this exception:

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 http://support.google.com/mail/bin/answer.py?answer=14257 wd7sm12843789wjc.36 - gsmtp "

Here is my mail config:

return array(
  'driver' => 'smtp',
  'host' => 'smtp.gmail.com',
  'port' => 465,
  'from' => array('address' => 'mymail@gmail.com', 'name' => 'myname'),
  'encryption' => 'ssl',
  'username' => 'mymail@gmail.com',
  'password' => 'lol',
  'sendmail' => '/usr/sbin/sendmail -bs',
  'pretend' => false,
);

The first time I got this message, I had to tell Google that he can trust this IP. But I'm still having this issue on my website and Google doesn't warn me anymore.

Is there a way to tell Google "stop blocking this IP, it's me" ?

Flobesst
  • 1,281
  • 1
  • 16
  • 26
  • 1
    A bit unrelated but; I use http://mandrillapp.com for sending e-mails. Laravel supports it :) – Thomas Jensen Sep 24 '14 at 13:25
  • Possible duplicate of [Laravel Gmail not working, "Username and Password not accepted. Learn more..."](http://stackoverflow.com/questions/25249476/laravel-gmail-not-working-username-and-password-not-accepted-learn-more) – PapaHotelPapa Feb 15 '16 at 21:16

3 Answers3

34

Since I posted this question, I found a way to solve this issue.

I activated 2-steps authentication for my Google account. Then I generated an application-specific password for my Gmail account and I put this password into my Laravel application.

Now Laravel can send e-mails through my Gmail account :)

Flobesst
  • 1,281
  • 1
  • 16
  • 26
  • 2
    It does not work for me, Getting this error: Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError e190sm2996547pfa.41 - gsmtp " – Kapil Yadav Sep 01 '17 at 10:53
12

Seems like your gmail is preventing the app that is trying to send a mail.

You've to enable the access to the laravel app.

Google's less secure enable

https://www.google.com/settings/security/lesssecureapps

goto that above link and choose enable and then try again. It'll work.

vickythegme
  • 367
  • 2
  • 13
0

In laravel 7. * I had problems for leaving null in MAIL_FROM_ADDRESS so I recommend you complete this field with a fake email.

MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=email_server@gmail.com
MAIL_PASSWORD=password_application_gmail
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=hello@gmail.com
MAIL_FROM_NAME="Name Aplication"