Last active
April 5, 2024 11:16
-
-
Save abenevaut/0c0dec362aed94b73f829a13e99b58b1 to your computer and use it in GitHub Desktop.
How to use the Laravel failover mail driver with mailhog ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# To test the failover, set MAIL_MAILER as local | |
# | |
MAIL_MAILER=local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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, | |
], | |
], | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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