In Laravel 5, mail configuration need to be done in .env file and mail.php files. In one of our projects, we have used the thrid
party mail server ‘mailgun’ for sending mail.
In .env file:
In the above configuration, the issue which we have faced was ‘mail driver’. Initially, it was ‘SMTP’ and then after lot of attempts,
we have used ‘sendmail’ as mail driver and it was worked ( Note: we have used godaddy hosting).
Once we configure the .env file and we need to add the same details in ‘config/mail.php’ file with additional information such as ‘from’ email address
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'firstname.lastname@example.org', 'name' => "Chatur"],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('email@example.com'),
'password' => env('55098439658e30bb9956e6124c5cafe5'),
you need to make sure that ‘ from email address’ should have domain name where you have hosted your application. For example: your website name is www.example.com. then
your from mail address may be ‘firstname.lastname@example.org’ or ‘email@example.com’ and it should not be like ‘firstname.lastname@example.org