Skip to content

Tips on testing email notifications

Send e-mails in test mode

We need to be able to send e-mails in test mode, because we should not deliver actual e-mails when not in production.

Mailgun

When using Mailgun, you need to use the same API key and define a parameter to say "we are in test mode".

  • When testing using the SMTP method, a parameter named X-Mailgun-Drop-Message set to true should be defined as a text header.
  • When testing using the API method, send a parameter named o:testmode set to true.

Sandbox

To use Mailgun’s sandbox ensure that you use the following parameters at your .env file:

text
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=sandboxc641e0a6438d4fd88d8e3fba682fb09e.mailgun.org
MAILGUN_SECRET=key-3506f37612c8217122135be0b54ffcec

WARNING

Be aware, Mailgun will send emails in sandbox mode only to emails from the list available at the https://mailgun.com/app/testing/recipients URL. For all other emails \Mail::send() method of Laravel’s Illuminate\Support\Facades\Mail facade will throw \GuzzleHttp\Exception\ClientException exception.