Integrations

Symfony

Symfony Mailer bridge providing native Mailtrap integration for Symfony apps.

How it works

Add Mailtrap as a transport for the Symfony Mailer component with our official bridge. Keep your existing logic and seamlessly send emails using Mailtrap’s robust infrastructure for high deliverability. Capture all test emails in a safe sandbox and leverage detailed analytics for your email sending, all within your Symfony ecosystem.

Configure

Step 1: Create a Mailtrap account, verify your domain, and get the API token.

Step 2: To get started quickly, run the following command: composer require railsware/mailtrap-php symfony/http-client nyholm/psr7 symfony/mailer

Step 3: Add MailtrapTransport into your config/services.yaml file.

...
    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    Mailtrap\Bridge\Transport\MailtrapSdkTransportFactory:
        tags:
            - { name: 'mailer.transport_factory' }

Step 4: Add or change MAILER_DSN variable inside your .env file, and change the YOUR_API_KEY_HERE placeholder.

MAILER_DSN=mailtrap+sdk://YOUR_API_KEY_HERE@default
# or
MAILER_DSN=mailtrap+sdk://YOUR_API_KEY_HERE@send.api.mailtrap.io

Step 5: Use the following CLI command to send your first email php bin/console mailer:test to@example.com

For more details and examples, check Mailtrap Symfony Bridge docs

Supported functionality

  • Email sending – transitional and bulk 
  • Batch sending
  • Contacts and contacts lists management
  • Templates management 
  • Sending domains management
  • Sending and getting sandbox emails
  • Managing sandbox projects