Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail locks account when sending mail via Laravel

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' => '[email protected]', 'name' => 'myname'),
  'encryption' => 'ssl',
  'username' => '[email protected]',
  '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" ?

like image 505
Flobesst Avatar asked Aug 07 '14 22:08

Flobesst


1 Answers

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 :)

like image 185
Flobesst Avatar answered Nov 19 '22 22:11

Flobesst