Send mail to Ravel mailhog test error Connection could not be established with host mailhog:stream_socket_client():

Asked 2 years ago, Updated 2 years ago, 282 views

We introduced mailhog to test mail transmission with Ravel, which is operated by docker.
However, an error has occurred and cannot be sent.

Swift_TransportException
Connection could not be established with host mailhog:stream_socket_client():php_network_getaddresses:getaddrinfo for mailhog failed:Temporary failure in name resolution

operating environment:
php 8.1.8
Ravel Framework 8.83.23
sail 8.1

For maihog deployment, we performed the following steps:
1) docker-compose.yml

mail:
    image:mailhog/mailhog
    container_name —mailhog
    ports:
        - "1025:1025"
        - "8025:8025"

2) .env

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

// Add
WWWGROUP = 1000
WWWUSER = 1000

3) Update docker-image
docker-compose build--no-cache

4) Launch sail sailup-d

5) Inbox confirmation for mailhog
http://localhost:8025Display successfully

6) Send mail=>Error
7) Attempted to change settings for error.
The same error occurs when MAIL_HOST in .env is maillocalhost

My hands are completely clogged.
Where else should I check?

php laravel sendmail

2022-09-30 22:05

1 Answers

mail:
    image:mailhog/mailhog
    container_name —mailhog
    ports:
        - "1025:1025"
        - "8025:8025"
    networks:
        - sail

As mentioned above, it was resolved by adding networks at the end.
Build with docker-compose build --no-cache after adding


2022-09-30 22:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.