Created
July 5, 2016 15:14
-
-
Save devudit/d1f83c59ca3d03cb4661c4014248eb90 to your computer and use it in GitHub Desktop.
Sending mail in Lumen via SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ). | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment