Configure Symfony2/Swiftmailer to use “sendmail -t”

吃可爱长大的小学妹 提交于 2019-11-28 13:47:01

I was looking for the same thing as you and i found that there is now a SendMailTransport class.

Here is the documentation : http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport

Just spent the day on this very issue.

I prefer using straight configuration for this kind of thing, and I found this to work:

# app/config/services.yml
services:
  swiftmailer.mailer.default.transport:
    class:     Swift_SendmailTransport
    arguments: ['/usr/sbin/sendmail -t']

This configuration should work.

mailer_transport: sendmail
mailer_host: /usr/bin/sendmail # wherever your mail is
#mailer_user: ~
#mailer_password: ~

If there is still problem,

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 .
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!