Lumen provides a clean, simple API over the popular SwiftMailer library with drivers for SMTP, Mailgun, SparkPost, Amazon SES, PHP's
sendmail, allowing you to quickly get started sending mail through a local or cloud based service of your choice.
Before using Laravel's mail drivers in Lumen, you will need to install the
illuminate/mail package via Composer. Then, you should register the
Illuminate\Mail\MailServiceProvider in your
Next, configure your mail options by copying the
mail.php configuration file from the full Laravel framework to the
config directory in the root of your project. Of course, you are free to adjust the configuration options as needed. If your Lumen application does not contain a
config directory, you should create it.
After creating the configuration file, you should register the mailer and its aliases within your
$app->configure('mail'); $app->alias('mail.manager', Illuminate\Mail\MailManager::class); $app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class); $app->alias('mailer', Illuminate\Mail\Mailer::class); $app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class); $app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
The following configuration options should also be available to your Lumen application's
MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME="Example app"
The Lumen mail drivers utilize the same code as the Laravel mail drivers. Beyond configuration, there are no differences between sending mail in Lumen and sending mail in Laravel; therefore, please consult the full Laravel documentation for usage examples.