Trying to get Laravel 5 email to work


I'm trying to send an email to a specified user by typing in the URL, but I'm getting the following error:

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

So far I'm just trying to get it to work with Gmail. How can I get this to work?

This is what I have so far: mail.php

    return [
        'driver' => env('MAIL_DRIVER',' smtp'),
        'host' => env('MAIL_HOST', ''),
        'port' => env('MAIL_PORT', 587),
        'from' => ['address' =>"[email protected]" , 'name' => "example"],
        'encryption' => 'tls',
        'username' => env('[email protected]'),
        'password' => env('MyPassword'),
        'sendmail' => '/usr/sbin/sendmail -bs',
        'pretend' => false,

This is what I have in the routes:

Route::get('test', function() {
    Mail::send('Email.test', [], function ($message) {
        $message->to('[email protected]', 'HisName')->subject('Welcome!');

This is what I have in my controller:

class MailController extends Controller
    public function Sending_Email()
        return View('Email.test');

And this is what is in my .env file:

[email protected]

This question is tagged with php laravel laravel-5 email-integration

~ Asked on 2015-03-17 13:53:15

The Best Answer is


I know it's working for you now @Vantheman6 but this is what worked for me in case it's the same for someone else.

I added to my .env file the details of the mail service I am using. So make sure the following details

[email protected]

in the .env file are accurate.

NOTE: Don't forget to restart your server after editing the .env file so it will pick the new data that you put in there.

Clear config cache with below command:

php artisan config:cache

If you don't restart your server, the .env file will still continue to present the old mail data to the app even though you have made changes that can cause this error.

~ Answered on 2015-03-24 15:47:32


My .env file configuration is like this for laravel 5.1

[email protected]

here most important thing is that I created gmail application specific password(16 digit).

I need to reveal one more thing since no luck for any of configuration. That is, whenever I changed .env file need to run this command

php artisan config:cache

And this is most most most important because without this command laravel executes previous settings from it's cache. It's required me more than 10 hours to figure out.

~ Answered on 2015-07-02 19:26:13

Most Viewed Questions: