176*_*764 5 swiftmailer symfony
我目前正在尝试让Symfony2/Swiftmailer通过邮件发送提交表单的内容.我的parameters.yml包含以下内容:
mailer_transport: sendmail
mailer_host: ~
mailer_user: ~
mailer_password: ~
Run Code Online (Sandbox Code Playgroud)
由于我服务器上的sendmail版本不支持-bsSwiftmailer默认使用的选项,我必须找到一种方法来告诉Symfony2/Swiftmailer使用sendmail -t.Swift_Transport_SendmailTransport似乎支持这一点,但似乎没有相应的SwiftmailerBundle配置选项.
如何告诉Swiftmailer使用sendmail -t(最好通过配置)?
编辑2:现在,我正在使用
$message = \Swift_Message::newInstance()
[…];
$transport = $this->get('swiftmailer.mailer.default.transport.real');
if ($transport instanceof \Swift_Transport_SendmailTransport) {
$transport->setCommand('/usr/sbin/sendmail -t');
}
$this->get('mailer')->send($message);
Run Code Online (Sandbox Code Playgroud)
不过,我仍然想知道是否有更好的方法来做到这一点.
小智 9
刚刚在这个问题上度过了一天.
我更喜欢直接配置这种东西,我发现这个工作:
# app/config/services.yml
services:
swiftmailer.mailer.default.transport:
class: Swift_SendmailTransport
arguments: ['/usr/sbin/sendmail -t']
Run Code Online (Sandbox Code Playgroud)
这种配置应该有效.
mailer_transport: sendmail
mailer_host: /usr/bin/sendmail # wherever your mail is
#mailer_user: ~
#mailer_password: ~
Run Code Online (Sandbox Code Playgroud)
如果还有问题,
A. check who are sending mail to someone@wxy.com
1. console - check your permission to access sendmail
2. web - check web user like wwww-data can access sendmail
B. check your mail log /var/log/maillog
When Symfony Swiftmailer send,
1. mail log has not been processed, then PHP side problem.
2. else if: send to outlook
it is TLS handshake problem, it might be from outlook tls handshake.
FYI, sendmail TLS is not working with outlook well.
add next line to /etc/mail/access
Try_TLS:wxy.com NO
3. else:
Sorry, google with mail log error messages again .
Run Code Online (Sandbox Code Playgroud)
小智 2
我一直在寻找与您相同的东西,我发现现在有一个 SendMailTransport 类。
这是文档:http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport
| 归档时间: |
|
| 查看次数: |
11714 次 |
| 最近记录: |