I'm trying to send mail through Mailhog using Laravel.
P粉715228019
P粉715228019 2023-07-30 12:49:58
0
1
421
<p>这里是我的 .env 文件:</p> <pre class="brush:php;toolbar:false;">APP_NAME=Laravel APP_ENV=local APP_KEY=base64:p5lGXZTf7OB8BwTkbRBiBxoVn0yOO06tSyP/iChZJGA= APP_DEBUG=true APP_URL=http://localhost LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=lara DB_USERNAME=root DB_PASSWORD=root BROADCAST_DRIVER=log CACHE_DRIVER=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 MEMCACHED_HOST=127.0.0.1 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_MAILER=smtp MAIL_HOST=mailhog MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS="hello@example.com" MAIL_FROM_NAME="${APP_NAME}" AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_HOST= PUSHER_PORT=443 PUSHER_SCHEME=https PUSHER_APP_CLUSTER=mt1 VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" VITE_PUSHER_HOST="${PUSHER_HOST}" VITE_PUSHER_PORT="${PUSHER_PORT}" VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"</pre> <p>我正在使用Docker,这是MailHog的部分:</p> <pre class="brush:php;toolbar:false;">mailhog: image: mailhog/mailhog ports: - 1025:1025 - 8025:8025</pre> <p>每当应该发送新邮件时,我遇到以下错误:无法与主机“mailhog:1025”建立连接:stream_socket_client():php_network_getaddresses:getaddrinfo for mailhog failed: Temporary failure in name resolution</p><p>我尝试通过mailhog发送邮件通知,但每当应该发送时都会遇到错误。</p><p><br /></p>
P粉715228019
P粉715228019

reply all(1)
P粉633733146

When creating a new Laravel project, developers often encounter an error. The project's default sender is set to Mailhog, which is only supported when using Laravel Sail as the development environment. Therefore, if a different development environment is used, the configuration needs to be modified to avoid problems.

In order to solve this problem, it is recommended to set the mail host and port in the .env file as follows:


MAIL_HOST=127.0.0.1
MAIL_PORT=1025
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template