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".

Note: If you run sendmail in "-t" mode you will get no feedback as to whether or not sending has succeeded. Use "-bs" unless you have a reason not to.

To use the Sendmail Transport:

  1. 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.
  2. 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);

NOTE: Documentation for version 3 is in the wiki.