webdevops / php-docker-boilerplate

:stew: PHP Docker Boilerplate for Symfony, Wordpress, Joomla or any other PHP Project (NGINX, Apache HTTPd, PHP-FPM, MySQL, Solr, Elasticsearch, Redis, FTP)
https://webdevops.io/projects/php-docker-boilerplate/
MIT License
562 stars 186 forks source link

How to use mailhog? #75

Closed vlados closed 6 years ago

vlados commented 6 years ago

I've tested every possible way to use mailhog as mail catcher but I always get this:

mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Starting session
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] [PROTO: INVALID] Started session, switching to ESTABLISH state
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Sent 35 bytes: '220 mailhog.example ESMTP MailHog\r\n'
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Received 2 bytes: '\r\n'
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] [PROTO: ESTABLISH] Processing line: 
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] [PROTO: ESTABLISH] In state 1, got command '', args ''
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] [PROTO: ESTABLISH] In ESTABLISH state
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] [PROTO: ESTABLISH] Got unknown command for ESTABLISH state: ''
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Sent 26 bytes: '500 Unrecognised command\r\n'
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Connection closed by remote host
mail_1   | 2018/02/28 22:57:29 [SMTP 127.0.0.1:41492] Session ended
htuscher commented 6 years ago

Mailhog is running out of the box.

The ENV variable POSTFIX_RELAYHOST=[mail]:1025 causes every sendmail command inside the app container to be redirected to the mailhog container.

If you use a PHP framework/application that has its own SMTP configuration, you can use this configuration:

SMTP-Host: mail
SMTP-Port: 1025

You don't need to specify any encryption, user or password.

Mailhog itself provides a HTTP interface that is running on port 8025 and can either be reached at http://mail.boilerplate.docker or http://boilerplate.docker:8025 (depending wether you use reverse proxy or not).