Last active
March 29, 2021 19:37
-
-
Save marinsagovac/34673716c757993cbb6be5b0c17c31ac to your computer and use it in GitHub Desktop.
Mailhog + Symfony 3
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
$message = \Swift_Message::newInstance() | |
->setSubject('Hello Email') | |
->setFrom('[email protected]') | |
->setTo('[email protected]') | |
->setBody('You should see me from the profiler!') | |
; | |
$this->get('mailer')->send($message); | |
Create a file 'docker-compose.yml' add: | |
mailhog: | |
image: 'mailhog/mailhog:latest' | |
container_name: mailhog | |
restart: always | |
ports: | |
- '8025:8025' | |
- '1025:1025' | |
Run `` then `docker run mailhog/mailhog`. | |
Check process: ˙docker-compose ps˙. | |
Run mailbox: http://0.0.0.0:8025/# | |
Set configuration in Symfony: | |
Set configuration: `parameters.yml`: | |
mailer_transport: smtp | |
mailer_host: 127.0.0.1:1025 | |
mailer_port: 1025 | |
mailer_user: null | |
mailer_password: null | |
# Swiftmailer Configuration | |
swiftmailer: | |
transport: '%mailer_transport%' | |
host: '%mailer_host%' | |
username: '%mailer_user%' | |
password: '%mailer_password%' | |
port: '%mailer_port%' | |
spool: { type: memory } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One comment to clarify to others that use a Symfony container, set the host as the name of the mailhog container, i.e. with the configuration above, the symfony app using the mailhog host need to inform:
host: mailhog