How to configure mailer?
Sylius uses SyliusMailerBundle, which is based on the Symfony Mailer to provide a powerful and customizable email system. This allows you to configure easily:
Environment-based mail transports
Email localization
Named email templates
🔧 Basic Setup
Sylius relies on Symfony's MAILER_DSN system to define the email provider. You’ll usually define this in your .env files.
Example (Using Mailtrap):
MAILER_DSN=smtp://username:[email protected]:2525To explore supported providers and DSN formats, refer to the official Symfony Mailer transport documentation.
✅ Example Configuration per Environment
Production (.env.prod)
.env.prod)In production, just provide a valid DSN.
# env.prod
MAILER_DSN=smtp://apikey:your-api-key@sendgridNo extra steps are needed unless you want to customize delivery logic (e.g., retry policies, queuing, etc.).
Development & Testing (.env.local / .env.test)
.env.local / .env.test)Two common options:
Option A: Disable Email Delivery (Default)
# for example env.local
MAILER_DSN=null://defaultEmails won’t be sent — great for running automated tests without side effects.
Option B: Use MailHog (Visual Email Debugger)
# for example env.local
MAILER_DSN=smtp://localhost:1025Launch MailHog and view emails at http://localhost:8025.
Last updated
Was this helpful?
