Using the Sendmail Transport
To use the Sendmail Transport you simply need to call Swift_SendmailTransport::newInstance() with the command as a parameter.
To use the Sendmail Transport you need to know where sendmail or another MTA exists on the server. Swift Mailer uses a default value of /usr/sbin/sendmail, which should work on most systems.
You specify the entire command as a parameter (i.e. including the command line flags). Swift Mailer supports operational modes of "-bs" (default) and "-t".
To use the Sendmail Transport:
- Call Swift_SendmailTransport::newInstance() with the command, including the correct command line flags. The default is to use /usr/sbin/sendmail -bs if this is not specified.
- Use the returned object to create the Mailer.
A sendmail process will be started upon the first call to send() or batchSend(). If the process cannot be started successfully an Exception of type Swift_Transport_TransportException will be thrown.
<?php
require_once 'lib/swift_required.php';
//Create the Transport
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);