我有以下设置/参数:
我想配置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: { }
更新github上发现的未解决问题:https://github.com/symfony/swiftmailer-bundle/issues/244
所以这是一个艰难的方式。但是在你的swiftmailer.yaml中尝试这个:
swiftmailer:
default_mailer: default
mailers:
default:
transport: sendmail
command: '%env(SENDMAIL_COMMAND)%'
timeout: 20
并在.env文件中添加一个新的env变量:
SENDMAIL_COMMAND='C:\Program Files (x86)\sendmail\sendmail.exe -t'
这是在第96行调试Swiftmailer Extension.php文件时发现的,你可以找到并且if语句可以帮助理解它是如何工作的