-
Notifications
You must be signed in to change notification settings - Fork 2
About MailHog service #1
Description
Hi Sam:
We were talking about how to configure the "docker-compose.yml" and the Laravel ".env" file on the chat of the Erika Heidi dockercon session (about "How to Create PHP Development Environments with Docker Compose") ... Maybe you remember our conversastion.
So, I download your repo and try it and the sending emails process works fine. No like mine.
The configuration of my "docker-compose.yml" and ".env" is similar to yours, but, when I launch the process to send and email, I have this message error on the browser:
Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:1025 (Connection refused)
Do you know what is the reason of this error?
I had the MAIL_HOST=127.0.0.1 but, after heard your advice, I changed it to the name of my Mailhog service name.
But even with that, I also don't fix the error, even if I follow your suggestions and put the same MAIL environment variables on the ".env" file. The error I receive is the same.
On the other hand, I realize that you name the MailHog service like "mailhog", the same reference for MAIL_HOST, and another inside the Dockerfile:
[docker-compose.yml]
mailhog:
image: mailhog/mailhog
[Dockerfile.app]
RUN echo '\n\
host mailhog\n\
port 1025\n\
from php-dev@example.com\n' \
>> /etc/msmtprc
[.env]
MAIL_HOST=mailhog
But, if the name of the services in the "docker-compose.yml" is a random personal choice, that is, that it is possible to put the name that you want to each service, then, if I replace "mailhog" with "mailhog_server" in the 3 references mentioned above, why the email sending process fails showing this error message?:
Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known
...even if rebuild the "php" service image with this command when I up the services:
docker-compose up -d --build
Where can a reference to the previous term persist (which, supposedly, would no longer have to exist after the change mentioned in each of the 3 files), even after a reconstruction of the "php" service?
So, only it can works if the reference is "mailhog"? and it is impossible that works if it is apply another name? Why?
And, another more question ... Is it necessary to put the Mailhog lines on the Dockerfile so that there can be a communication between the PHP application and the MailHog server and therefore the emails are sent? If you don't put this lines on the Dockerfile, the email sending process doesn't work?
Where did you get the idea of putting that MailHog reference into the Dockerfile? I have not seen anything like it in the MailHog documentation and much less, they say it is necessary.
I would appreciate receiving a response from you ... Best regards.