Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • SensioLabs Professional services to help you with Symfony
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Reference
  4. SwiftmailerBundle Configuration ("swiftmailer")
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Configuration
    • transport
    • username
    • password
    • host
    • port
    • encryption
    • auth_mode
    • spool
    • sender_address
    • antiflood
    • delivery_address
    • disable_delivery
    • logging
  • Full Default Configuration

SwiftmailerBundle Configuration ("swiftmailer")

Edit this page

Warning: You are browsing the documentation for Symfony 2.1, which is no longer maintained.

Read the updated version of this page for Symfony 6.2 (the current stable version).

SwiftmailerBundle Configuration ("swiftmailer")

This reference document is a work in progress. It should be accurate, but all options are not yet fully covered. For a full list of the default configuration options, see Full Default Configuration

The swiftmailer key configures Symfony's integration with Swiftmailer, which is responsible for creating and delivering email messages.

Configuration

  • transport
  • username
  • password
  • host
  • port
  • encryption
  • auth_mode
  • spool
    • type
    • path
  • sender_address
  • antiflood
    • threshold
    • sleep
  • delivery_address
  • disable_delivery
  • logging

transport

type: string default: smtp

The exact transport method to use to deliver emails. Valid values are:

  • smtp
  • gmail (see How to use Gmail to send Emails)
  • mail
  • sendmail
  • null (same as setting disable_delivery to true)

username

type: string

The username when using smtp as the transport.

password

type: string

The password when using smtp as the transport.

host

type: string default: localhost

The host to connect to when using smtp as the transport.

port

type: string default: 25 or 465 (depending on encryption)

The port when using smtp as the transport. This defaults to 465 if encryption is ssl and 25 otherwise.

encryption

type: string

The encryption mode to use when using smtp as the transport. Valid values are tls, ssl, or null (indicating no encryption).

auth_mode

type: string

The authentication mode to use when using smtp as the transport. Valid values are plain, login, cram-md5, or null.

spool

For details on email spooling, see How to Spool Emails.

type

type: string default: file

The method used to store spooled messages. Currently only file is supported. However, a custom spool should be possible by creating a service called swiftmailer.spool.myspool and setting this value to myspool.

path

type: string default: %kernel.cache_dir%/swiftmailer/spool

When using the file spool, this is the path where the spooled messages will be stored.

sender_address

type: string

If set, all messages will be delivered with this address as the "return path" address, which is where bounced messages should go. This is handled internally by Swiftmailer's Swift_Plugins_ImpersonatePlugin class.

antiflood

threshold

type: string default: 99

Used with Swift_Plugins_AntiFloodPlugin. This is the number of emails to send before restarting the transport.

sleep

type: string default: 0

Used with Swift_Plugins_AntiFloodPlugin. This is the number of seconds to sleep for during a transport restart.

delivery_address

type: string

If set, all email messages will be sent to this address instead of being sent to their actual recipients. This is often useful when developing. For example, by setting this in the config_dev.yml file, you can guarantee that all emails sent during development go to a single account.

This uses Swift_Plugins_RedirectingPlugin. Original recipients are available on the X-Swift-To, X-Swift-Cc and X-Swift-Bcc headers.

disable_delivery

type: Boolean default: false

If true, the transport will automatically be set to null, and no emails will actually be delivered.

logging

type: Boolean default: %kernel.debug%

If true, Symfony's data collector will be activated for Swiftmailer and the information will be available in the profiler.

Full Default Configuration

  • YAML
  • XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
swiftmailer:
    transport:            smtp
    username:             ~
    password:             ~
    host:                 localhost
    port:                 false
    encryption:           ~
    auth_mode:            ~
    spool:
        type:                 file
        path:                 "%kernel.cache_dir%/swiftmailer/spool"
    sender_address:       ~
    antiflood:
        threshold:            99
        sleep:                0
    delivery_address:     ~
    disable_delivery:     ~
    logging:              "%kernel.debug%"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<swiftmailer:config
    transport="smtp"
    username=""
    password=""
    host="localhost"
    port="false"
    encryption=""
    auth_mode=""
    sender_address=""
    delivery_address=""
    disable_delivery=""
    logging="%kernel.debug%"
>
    <swiftmailer:spool
        path="%kernel.cache_dir%/swiftmailer/spool"
        type="file"
    />

    <swiftmailer:antiflood
        sleep="0"
        threshold="99"
    />
</swiftmailer:config>
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Take the exam at home

    Take the exam at home

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Ahmed Ashraf, a Symfony contributor

    Thanks Ahmed Ashraf (@ahmedash95) for being a Symfony contributor

    4 commits • 220 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Algolia