Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel Expected response code 250 but got code "530"

Im trying to Mail in Laravel 5.1

my mail.php code is

 return [
     'driver' => env('MAIL_DRIVER', 'smtp'),
     'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
     'port' => env('MAIL_PORT', 587),
     'from' => ['address' => '[email protected]', 'name' => 'sample'],
     'encryption' => env('MAIL_ENCRYPTION', 'tls'),
     'username' => env('MAIL_USERNAME'),
     'password' => env('MAIL_PASSWORD'),
     'sendmail' => '/usr/sbin/sendmail -bs',
     'pretend' => env('MAIL_PRETEND', false),

 ];

my .env file is

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null

my function to email is

public function sendEmailVerification()
{
    $user = $this->user;//retrieved by $request->user() in __construct

    Mail::send('emails.verifyemail', ['user' => $user], function ($m) use ($user) {
        $m->from('[email protected], 'sample');

        $m->to($user->email, $user->name)->subject('Verify Email');
    });
}

Error appears every time i call my function.

Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. l188sm21749863pfl.28 - gsmtp"

like image 1000
mendz Avatar asked Mar 03 '17 08:03

mendz


Video Answer


2 Answers

I had the same problem. I changed,

MAIL_ENCRYPTION=null to 
MAIL_ENCRYPTION=tls 

php artisan config:cache

and it worked.

like image 54
AmarjaPatil4 Avatar answered Sep 28 '22 00:09

AmarjaPatil4


you need to enable your 2 step verification from gmail account.

https://myaccount.google.com/security

then use the generated key from there to your ENV_PASSWORD instead your real password.

like image 26
Winston Fale Avatar answered Sep 28 '22 01:09

Winston Fale