刷新电子邮件队列时发生异常:无法与主机localhost建立连接[无法分配请求的地址#99]

问题描述 投票:-1回答:1

我的symfony 4演示应用程序无法使用dev默认swiftmailer配置发送电子邮件。我的应用程序在一个php-fpm docker容器中,我的conf为swiftmailer是

MAILER_URL=smtp://localhost:25

这是我的日志

[2017-12-17 15:48:43] php.DEBUG: Warning: stream_socket_client(): unable to connect to localhost:25 (Cannot assign requested address) 

[2017-12-17 15:48:43] app.ERROR: Exception occurred while flushing email queue: Connection could not be established with host localhost [Cannot assign requested address #99] [] []

提前致谢。

php docker swiftmailer symfony4
1个回答
0
投票

我通过添加一个mailcatcher容器来解决这个问题。将它添加到你的docker-compose文件中

mailcatcher:
    image: yappabe/mailcatcher
    ports:
        - 1025:1025
        - 1080:1080

然后添加您的邮件程序URL配置

MAILER_URL=smtp://mailcatcher:1025

您可以在以下网址查看电子邮件:1080

© www.soinside.com 2019 - 2024. All rights reserved.