I'm currently trying to get Symfony2/Swiftmailer to send the contents of a submitted form via mail. My parameters.yml contains the following:
mailer_transport: sendmail
mailer_host: ~
mailer_user: ~
mailer_password: ~
Since the sendmail version on my server does not support the -bs
option, which Swiftmailer seems to use by default, I have to find a way to tell Symfony2/Swiftmailer to use sendmail -t
instead. Swift_Transport_SendmailTransport
seems to support that, but there doesn't seem to be a corresponding configuration option for SwiftmailerBundle.
How do I tell Swiftmailer to use sendmail -t
(preferrably via configuration)?
Edit 2: For now, I'm using
$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);
I'm still wondering if there's a better way to do this, though.