Emails
Configure your email service.
Email providers
Local / Testing
Mailtrap
I personally use Mailtrap for emails in local environment, so it’s my recommendation. This doesn’t mean other services mentioned below are worse or better in any way.
https://laravel.com/docs/11.x/mail#mailtrap
- Create and setup Mailtrap account
- Update
.env
file with Mailtrap credentials
HELO
Coming soon…
Mailpit
Coming soon…
Production / Staging
doesn’t come with any pre-installed email service since there is not one that fits all cases, and it’s actually very easy to setup any of the services mentioned below.
To implement desired mail service, just follow the instructions below or official Laravel docs.
Mailgun
Coming soon…
Postmark
Coming soon…
Resend
Coming soon…
MailerSend
- Install the package:
- Create a MailerSend account.
Once your are logged in, go to Email - Domains to add your domain. You should also approve your account to avoid limitations.
- Go to Integrations and create API token for your domain. Update your
.env
file:
- Add MailerSend to
config/mail.php
configuration file insidemailers
array:
Custom
https://laravel.com/docs/11.x/mail#custom-transports
Coming soon…
Queue emails
All emails are sent using Laravel’s deferred functions. If you need to send large amount of emails it’s recommended to send them in queues.
Setup local queue
https://laravel.com/docs/11.x/mail#queueing-mail
Docs coming soon…
Setup queue worker
Docs coming soon…
Laravel Horizon
Docs coming soon…
Previews emails
You can preview emails in local environment.
Preview routes are defined in routes/emails.php
route file.
Here is the list of all email preview routes (each route is prefixed with /email-previews
):
/email-verification
Email sent upon user registration (when email verification is enabled)/password-reset
Email sent upon password reset request/subscribed
Email sent upon successful subscription
Email templates
Default emails are rendered using markdown files located in resources/views/mail
folder.
Main message layout: resources/views/vendor/mail/html/message.blade.php
List of all components used in email templates are located in resources/views/vendor/mail/html
folder:
- layout: Main HTML file to render email template. You should probably leave this as-is.
- header: Application name with link to website, positioned above the content. You can update it to show your logo or anything relevant.
- footer: Copyright text below the content.
- panel: Highlighted text block.
- table: Table block.
- button: Action button. Accepts three parameters: color: primary (default), blue, green/success, red/error; url and align: left, right, center (default). You can add custom colors to default.css
button-{color_name}
- subcopy: Smaller text used as disclaimer.
- salutation: Included in message component.
To change style, you can update resources/views/vendor/mail/html/themes/default.css
CSS file.