3

I set this up to send mail by laravel 5 from my gmail account.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=********@gmail.com //email address
MAIL_PASSWORD="*******" //password for that email
MAIL_ENCRYPTION=tls

To test the mail sending, I used this one

Route::get('/email', function(){
$data = array(
    'name' => "Library",
    );
Mail::send('mailview',$data,function($message){
    $message->from('*******@gmail.com','Library');
    $message->to('*******@gmail.com')->subject('Confirmation mail.');
});

return "A email has been sent to you. Check inbox. Also check spambox if not in inbox.";});

But this gives me the following error.

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. g20sm4065212pfd.55 - gsmtp "

I googled for this and found some questions on SO related to this. And understood so far that the settings for gmail security is the culprit here.But didn't found any answer which describes what to do to solve this. Now I want to know how should I configure my gmail account? [Let's assume I have just created a new gmail account.Working on linux mint-if this info help you in anyway.]

jtbandes
  • 115,675
  • 35
  • 233
  • 266
Shafi
  • 1,850
  • 3
  • 22
  • 44

3 Answers3

4

Difference between port 465 and 587:

Port 465 is for smtps - SSL encryption is started automatically before any SMTP level communication.

Port 587 is for msa - it is almost like standard SMTP port. SSL encryption may be started by STARTTLS command at SMTP level if server supports it and your ISP does not filter server's EHLO reply (reported 2014 Nov).

(source)

so if you want to use port number 587, you should set encryption empty in your settings, but for 465, setting 'ssl' as encryption will fix the problem:

'host' => 'smtp.gmail.com',
'port' => 465, 
'encryption' => 'ssl',

OR

'host' => 'smtp.gmail.com',
'port' => 587, 
'encryption' => '',
Community
  • 1
  • 1
‌‌R‌‌‌.
  • 2,818
  • 26
  • 37
1

Not sure what happened.

port 587 should work.

Will you try by creating a new project and configure the settings like you wrote here?

I think everything here is okay. There may be other issue(s) with your project settings.

Once I faced something like this and creating a new project worked for me.

0

Maybe you need to enable Less Secure App Access in your gmail account.

infernaze
  • 61
  • 1
  • 6