2013-09-23 59 views
5

Tôi hiện đang cố gắng tải Symfony2/Swiftmailer để gửi nội dung của biểu mẫu đã gửi qua thư. parameters.yml My chứa sau:Cấu hình Symfony2/Swiftmailer để sử dụng "sendmail -t"

mailer_transport: sendmail 
mailer_host: ~ 
mailer_user: ~ 
mailer_password: ~ 

Kể từ khi phiên bản sendmail trên máy chủ của tôi không hỗ trợ tùy chọn -bs, mà Swiftmailer dường như sử dụng theo mặc định, tôi phải tìm một cách để nói Symfony2/Swiftmailer sử dụng Thay vào đó, sendmail -t. Swift_Transport_SendmailTransport dường như hỗ trợ điều đó, nhưng dường như không có tùy chọn cấu hình tương ứng cho SwiftmailerBundle.

Làm cách nào để yêu cầu Swiftmailer sử dụng sendmail -t (tốt nhất là thông qua cấu hình)?

Chỉnh sửa 2: Còn bây giờ, tôi đang sử dụng

$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); 

Tôi vẫn tự hỏi nếu có một cách tốt hơn để làm điều này, mặc dù.

Trả lời

6

Cấu hình này sẽ hoạt động.

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

Nếu vẫn còn là vấn đề,

A. check who are sending mail to [email protected] 
    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 . 
5

Chỉ cần dành cả ngày về vấn đề này rất.

tôi thích sử dụng cấu hình thẳng cho loại điều, và tôi thấy điều này để làm việc:

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