Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abenevaut/0c0dec362aed94b73f829a13e99b58b1 to your computer and use it in GitHub Desktop.
Save abenevaut/0c0dec362aed94b73f829a13e99b58b1 to your computer and use it in GitHub Desktop.
How to use the Laravel failover mail driver with mailhog ?
#
# To test the failover, set MAIL_MAILER as local
#
MAIL_MAILER=local
version: '3'
#
# docker-compose up -d
#
services:
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025
mailhog_jim:
image: mailhog/mailhog
ports:
- 8026:8025
- 1026:1025
command: -invite-jim=1 -jim-accept=0.40
depends_on:
- mailhog
<?php // config/mail.php
return [
'default' => env('MAIL_MAILER', 'production'),
'mailers' => [
'local' => [
'transport' => 'failover',
'mailers' => [
'mailhogWithJim', // we use our local mailers
'mailhog', // they are defined below
'log',
],
],
'production' => [
'transport' => 'failover',
'mailers' => [
/*
* Add your own mailer(s)
* Use `mailhog` & `mailhogWithJim` as example
*/
'log',
],
],
'testing' => [
'transport' => 'array',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'mailhog' => [
'transport' => 'smtp',
'host' => '127.0.0.1',
'port' => 1025,
'encryption' => null,
'username' => null,
'password' => null,
'timeout' => null,
'local_domain' => null,
],
'mailhogWithJim' => [
'transport' => 'smtp',
'host' => '127.0.0.1',
'port' => 1026,
'encryption' => null,
'username' => null,
'password' => null,
'timeout' => null,
'local_domain' => null,
],
],
];
#
# If you do not use docker to run MailHog,
# it have to be installed on your computer and registered in PATH env var
#
MailHog
MailHog -smtp-bind-addr=0.0.0.0:1026 -ui-bind-addr=0.0.0.0:8026 -api-bind-addr=0.0.0.0:8026 -invite-jim -jim-accept=0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment