Skip to content

Delivery providers

laraspring/mail does not send anything. Laravel's mailers do, and they are already good: SES, Postmark, Resend, Mailgun, SMTP, plus log and array for development. Putting an adapter layer of our own in front of them would add a seam with nothing on the other side of it.

So this page is short on purpose. Pick a transport, set its env keys, done.

Choosing one

dotenv
MAIL_MAILER=ses
MAIL_FROM_ADDRESS="hello@yourdomain.com"
MAIL_FROM_NAME="${APP_NAME}"

Everything else is per-transport. The mailer definitions live in config/mail.php, unchanged from Laravel's own.

Amazon SES

dotenv
MAIL_MAILER=ses
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=eu-west-1
bash
composer require aws/aws-sdk-php

Cheapest at volume and the most work to start with: a new account is sandboxed until you ask AWS to lift it, and until then it will only deliver to addresses you have verified.

Postmark

dotenv
MAIL_MAILER=postmark
POSTMARK_TOKEN=
bash
composer require symfony/postmark-mailer symfony/http-client

Transactional-only by policy, which is why its deliverability is what it is. Use a separate message stream for anything promotional.

Resend

dotenv
MAIL_MAILER=resend
RESEND_API_KEY=
bash
composer require resend/resend-php

Mailgun

dotenv
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=
MAILGUN_SECRET=
MAILGUN_ENDPOINT=api.eu.mailgun.net   # EU region only
bash
composer require symfony/mailgun-mailer symfony/http-client

SMTP

Works with anything, including a provider not listed here.

dotenv
MAIL_MAILER=smtp
MAIL_HOST=
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls

Development

The kit ships with MAIL_MAILER=log, which writes the rendered message into storage/logs/laravel.log and sends nothing. To read email as email, point SMTP at Mailpit and open its web UI:

dotenv
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025

For looking at wording and layout, the preview browser is faster than either: it renders the real templates with no flow to trigger and no inbox to open.

In tests, Mail::fake() and Notification::fake() work exactly as they do in any Laravel application. The package suites run with MAIL_MAILER=array.

Staying out of the spam folder

None of this is laraspring-specific, and all of it matters more than the template.

  • Authenticate the domain. SPF, DKIM and a DMARC record. Every provider above documents the exact DNS entries; without them you are guessing.
  • Send from a domain you own, never from the recipient's (from: user@gmail.com fails DMARC at Gmail). Put the user in Reply-To instead.
  • Keep transactional and marketing on separate streams or subdomains, so a campaign that gets complaints cannot take your password resets down with it.
  • Queue your mail. ShouldQueue on a notification means a provider having a bad morning is a retry rather than a failed request in front of a user. The kit's notifications already use the Queueable trait.

Failover

Two transports, tried in order, is a Laravel feature rather than something this package adds:

php
// config/mail.php
'default' => 'failover',

'mailers' => [
    'failover' => [
        'transport' => 'failover',
        'mailers' => ['postmark', 'ses'],
    ],
],

Worth it once sign-in emails are the only way into your product.

Laraspring is a commercial starter kit. Buying it gets you the source.