【发布时间】:2019-02-22 14:40:20
【问题描述】:
我有以下设置/参数:
- PHP 7.1.26
- Windows 10 x64 专业版
- symfony/swiftmailer-bundle 3.5.2
- symfony/控制台 4.1.11
我想将 swiftmailer-bundle 配置为使用fake sendmail,它安装在
C:\Program Files (x86)\sendmail
虽然我已经在 PHP 中配置了 sendmail_path,但 swiftmailer-bundle 实际上并没有使用这个 PHP 变量。相反,它将 sendmail 可执行文件的路径默认为
/usr/sbin/sendmail -bs
但是,从 3.0.4 版本开始,路径(即完整的命令)应该是可配置的:https://github.com/symfony/swiftmailer-bundle/pull/185
我放了
swiftmailer:
mailers:
default:
transport: sendmail
command: 'C:\Program Files (x86)\sendmail\sendmail.exe -t'
进入我的app/config/config.yml 并重建缓存。但是,当我想通过发送测试电子邮件时
swiftmailer:email:send
它仍然使用默认命令 - 当然会失败
[Swift_TransportException]
Process could not be started [The system cannot find the specified path.]
我不确定我还能尝试什么。我真的很想在我的本地环境中使用虚假的 sendmail 设置,因为可以将 sendmail 配置为强制将任何电子邮件发送到特定地址(我的地址)进行测试并始终使用特定的 SMTP。
这是debug:config swiftmailer的输出:
swiftmailer:
default_mailer: default
mailers:
default:
transport: sendmail
host: 127.0.0.1
username: null
password: null
port: 25
encryption: null
command: 'C:\Program Files (x86)\sendmail\sendmail.exe -t'
url: null
timeout: 30
source_ip: null
local_domain: null
auth_mode: null
delivery_addresses: { }
logging: false
delivery_whitelist: { }
【问题讨论】:
-
您是否尝试过使用双斜杠:'C:\\Program Files (x86)\\sendmail\\sendmail.exe -t' 而不是 shure 关于空格 :)
-
在文档glob.com.au/sendmail 中也有一个指向堆栈的链接:) - stackoverflow.com/questions/21337859/sendmail-wamp-php
-
@myxaxa:没有——但我确实在 Swiftmailer 的代码中进行了调试,而配置根本没有到达
Swift_SendmailTransport类。它仍然使用默认的/usr/sbin/sendmail -bs。 -
@myxaxa:Stackoverflow 链接仅涉及 PHP 配置。 Swiftmailer Bundle 不使用 PHP 配置。
-
抱歉回复晚了。有点奇怪。您确定您的项目中没有其他用于 swiftmailer 的配置吗?请运行以下命令:php bin/console debug:config swiftmailer 并显示输出symfony.com/doc/current/reference/configuration/…
标签: php windows symfony sendmail swiftmailer