-1

i used

$email = $dist->email;
Mail::send('emails.welcome', $input1, function ($message) use($input1,$email) {
     $message->from('myemail@gmail.com', "Messenger");
     $message->subject("New User Registered");
     $message->to($email);
});

and my .env file is

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=psw
MAIL_ENCRYPTION=tls

Yes this i got from Stack overflow. But unfortunately its not working. Gone through the several answers. Finally ended up asking here. also there is no errors in

my config/mail.php

  <?php

return [



    'driver' => env('MAIL_DRIVER', 'smtp'),



    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),


    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],



    'encryption' => env('MAIL_ENCRYPTION', 'tls'),



    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),



    'sendmail' => '/usr/sbin/sendmail -bs',



    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];            

Is its necessary to generate the separate app password to use gmail id as username?

  • 1
    I guess you forget to add reference to the previous SO answer. ([It is recommended to reference them.](https://meta.stackexchange.com/questions/271080/the-mit-license-clarity-on-using-code-on-stack-overflow-and-stack-exchange)) – Gábor Bakos Oct 24 '18 at 06:07
  • did config/mail.php configured correctly? – Rp9 Oct 24 '18 at 06:07

1 Answers1

-1

Reason might be your config/mail.php file have not port details.Try after adding 'port' => env('MAIL_PORT', 587),.

I hope this will help.