2013-09-23 16 views
5

Obecnie próbuję uzyskać, aby Symfony2/Swiftmailer wysłał zawartość przesłanego formularza pocztą. Moja parameters.yml zawiera następujące elementy:Skonfiguruj Symfony2/Swiftmailer do użycia "sendmail -t"

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

Ponieważ sendmail wersja na mój serwer nie obsługuje opcję -bs, który Swiftmailer wydaje domyślnie używać, muszę znaleźć sposób, aby powiedzieć Symfony2/Swiftmailer używać sendmail -t zamiast tego. Swift_Transport_SendmailTransport wydaje się to wspierać, ale wydaje się, że nie ma odpowiedniej opcji konfiguracyjnej dla SwiftmailerBundle.

Jak mogę powiedzieć, że Swiftmailer może używać sendmail -t (najlepiej przez konfigurację)?

Edit 2: Na razie używam

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

Nadal zastanawiam się, czy jest jakiś lepszy sposób to zrobić, choć.

Odpowiedz

6

Taka konfiguracja powinna działać.

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

Jeśli nadal problem

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

Właśnie spędziłem dzień na tym samym numerze.

Wolę za pomocą prostej konfiguracji dla tego typu rzeczy, i znalazłem to do pracy:

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