Laravel 无法建立邮件连接 Mailhog
Laravel Mail Connection could not be established Mailhog
我已经安装了 Laravel Breeze,但 'forgot password' 功能不起作用。
登录和注册都运行良好,所以我猜发送恢复电子邮件时出了点问题。
这是显示的错误:
"Connection could not be established with host "mailhog:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution"
在 Symfony \ Component⟩\ Mailer⟩\ Exception⟩\ TransportException.
这是截图:
error
这是我的 .env 文件的一部分:
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}"
环境是:
- Ubuntu 21.10
- Laravel 9.7.0
- PHP 8.0.8
通过php artisan serve
测试
这是一个新的 Laravel 项目,我在其中只安装了 Laravel Breeze 用于登录处理。 Laravel Sail 已安装。
您需要在 hosts 文件中添加此 127.0.0.1 mailhog
并在 .env 文件中更改此 MAIL_HOST=0.0.0.0
或使用 MAIL_HOST=localhost
您还可以检查您的 mailhog 是否已启用
sudo service mailhog status
启用:
sudo systemctl enable mailhog
开始:
sudo systemctl start mailhog
我已经安装了 Laravel Breeze,但 'forgot password' 功能不起作用。 登录和注册都运行良好,所以我猜发送恢复电子邮件时出了点问题。
这是显示的错误:
"Connection could not be established with host "mailhog:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution"
在 Symfony \ Component⟩\ Mailer⟩\ Exception⟩\ TransportException.
这是截图: error
这是我的 .env 文件的一部分:
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}"
环境是:
- Ubuntu 21.10
- Laravel 9.7.0
- PHP 8.0.8
通过php artisan serve
这是一个新的 Laravel 项目,我在其中只安装了 Laravel Breeze 用于登录处理。 Laravel Sail 已安装。
您需要在 hosts 文件中添加此 127.0.0.1 mailhog
并在 .env 文件中更改此 MAIL_HOST=0.0.0.0
或使用 MAIL_HOST=localhost
您还可以检查您的 mailhog 是否已启用
sudo service mailhog status
启用:
sudo systemctl enable mailhog
开始:
sudo systemctl start mailhog