emerico
7/5/2016 - 3:14 PM

Sending mail in Lumen via SMTP

Sending mail in Lumen via SMTP

<?php
/*
I believe you already install lumen, Now we need ‘illuminate\mail’ for sending 
mail through lumen so here is how i configure smtp mail with lumen.

1:- Install illuminate\mail to your lumen setup by entering following command
*/
composer require illuminate\mail
/*
2:- Edited the bootstrap/app.php uncommenting the following lines
*/
$app->withFacades();
/*
And
*/
$app->register(App\Providers\AppServiceProvider::class);
/*
3:- Open up your app/Providers/AppServiceProvider.php and in the register method, add the following
*/
$this->app->singleton('mailer', function ($app) { 
	$app->configure('services'); 
	return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer'); 
});
/*
This will enable the Mail

NOTE: If you haven’t got it already, you will need to copy/create the config/mail.php 
file:https://github.com/laravel/laravel/blob/master/config/mail.php
( Or you can get above file from laravel’s config directory )

Once you have it in place, make sure to modify the ‘from’ key, otherwise you’ll get 
Swift_TransportException ( A error Cannot send message without a sender address ).
*/