I got some trouble with mails generation on my Symfony app :
I use docker when I use Gmail to send emails :
MAILER_URL=gmail://[email protected]:MyPw@localhost
everything works fine
but as soon as I try to intercept these mails :
======================
Like this for mailtrap
MAILER_DSN=smtp://b3f077aeceaeb6:[email protected]:2525?encryption=tls&auth_mode=login
MAILER_URL=smtp://smtp.mailtrap.io:25&auth_mode=login&username=b3f077aeceaeb6&password=8792a1811dd8ef
or like this for mailHog
MAILER_DSN=smtp://localhost:1025
MAILER_URL="smtp://mailhog:1025?encryption=ssl&auth_mode=login&username=null&password=null"
my docker-compose.yml looks like this :
mailhog:
container_name: mailhog
restart: always
image: mailhog/mailhog:latest
ports:
-'8025:8025'
-'1025:1025'
Does anyone know how to see the mails displayed in mailhog? mailhog page is loaded correctly but nothing shows in it. The function sending the mail is entered, so this must be a configuration problem in my opinion
You need to narrow down the issue.
1. Can you send you an email via
telnetoropenssl(in case of STARTTLS)?Via telnet: https://mediatemple.net/community/products/dv/204404584/sending-or-viewing-emails-using-telnet
Via OpenSSL: https://www.stevenrombauts.be/2018/12/test-smtp-with-telnet-or-openssl/
Go through the tutorial (or any on this topic) and make sure your MAILER_URL is correct (including credentials, port, etc). The last time I had some issue with email, turned out that the firewall was blocking me.
Don't be quick to rule out networking issues.
2. Once you confirmed that you can send an email via Telnet/OpenSSL:
you need to go level up and try to configure the URL in Symfony and attempt sending via
swiftmailer:sendcommand. This may reveal some odd configuration issues in Symfony and you can fix them accordingly3. Repeat (1) and (2) but from Docker container.
Just
execinto Docker and do it all over again. This may reveal some issues in Docker network configuration, which you can fix.Please update your question with more findings and we could probably help you further...