Flow Swiftmailer 6.0 Documentation

This package allows to easily use the Swift Mailer library with Flow applications.

This version of the documentation covering release 6.0.5 has been rendered at: Mar 04, 2019


The package can be installed via composer:

composer require neos/swiftmailer


To set up the mail transport to be used, adjust the settings as needed. Without any further configuration, mails will be sent using Swift_MailTransport which uses the PHP mail() function. To use SMTP for sending, follow the following example:

      type: 'Swift_SmtpTransport'
        host: 'smtp.example.com'
        port: '465'
        encryption: 'ssl'
        username: 'myaccount@example.com'
        password: 'shoobidoo'
        localDomain: 'example.com'

The encryption property supports values ssl and tls.

Further transports are available with Swift Mailer and can be used as well. Their options can be looked up the Swift Mailer documentation and they can be set by extrapolating from their setter method names (as in: setUsername() becomes username in the options.)

Sending mail

If a transport is configured, sending mail is as simple as this:

  • create new Neos\SwiftMailer\Message instance
  • set your sender address with setFrom()
  • set a subject line with setSubject()
  • set recipients with setTo(), setCc(), setBcc()
  • set a body with setBody()
  • add attachments with attach()
  • send with send()

Here is an example:

$mail = new \Neos\SwiftMailer\Message();

        ->setFrom(array($senderAddress => $senderName))
        ->setTo(array($recipientAddress => $recipientName))

$mail->setBody($message, 'text/html');
$mail->setBody($message, 'text/plain');


Debugging sent mail

To debug sent mails, an easy way is to configure the transport to the the mbox handler of this package. If this is done in a context-specific configuration (for Development or a sub-context on a staging server), it can be safely committed to a VCS:

      type: 'Neos\SwiftMailer\Transport\MboxTransport'
        mboxPathAndFilename: '%FLOW_PATH_DATA%/Persistent/sent-mail'

All sent mails will be added to the configured mbox file and can be read with any client that can handle the mbox file format.

A second option is to use the LoggingTransport, which logs all mails to the SystemLog of Flow:

      type: 'Neos\SwiftMailer\Transport\LoggingTransport'