|
| 1 | +# Using Different Mailer Transports in phpList |
| 2 | + |
| 3 | +This document explains how to use the various mailer transports that are included in the phpList core dependencies: |
| 4 | + |
| 5 | +- Google Mailer (Gmail) |
| 6 | +- Amazon SES |
| 7 | +- Mailchimp Transactional (Mandrill) |
| 8 | +- SendGrid |
| 9 | + |
| 10 | +## Configuration |
| 11 | + |
| 12 | +The phpList core uses Symfony Mailer for sending emails. The mailer transport is configured using the `MAILER_DSN` environment variable, which is defined in `config/parameters.yml`. |
| 13 | + |
| 14 | +## Available Transports |
| 15 | + |
| 16 | +### 1. Google Mailer (Gmail) |
| 17 | + |
| 18 | +To use Gmail as your email transport: |
| 19 | + |
| 20 | +``` |
| 21 | +# Using Gmail with OAuth (recommended) |
| 22 | +MAILER_DSN=gmail://USERNAME:APP_PASSWORD@default |
| 23 | +
|
| 24 | +# Using Gmail with SMTP |
| 25 | +MAILER_DSN=smtp://USERNAME:[email protected]:587 |
| 26 | +``` |
| 27 | + |
| 28 | +Notes: |
| 29 | +- Replace `USERNAME` with your Gmail address |
| 30 | +- For OAuth setup, follow [Symfony Gmail documentation](https://symfony.com/doc/current/mailer.html#using-gmail-to-send-emails) |
| 31 | +- For the SMTP method, you may need to enable "Less secure app access" or use an App Password |
| 32 | + |
| 33 | +### 2. Amazon SES |
| 34 | + |
| 35 | +To use Amazon SES: |
| 36 | + |
| 37 | +``` |
| 38 | +# Using API credentials |
| 39 | +MAILER_DSN=ses://ACCESS_KEY:SECRET_KEY@default?region=REGION |
| 40 | +
|
| 41 | +# Using SMTP interface |
| 42 | +MAILER_DSN=smtp://USERNAME:[email protected]:587 |
| 43 | +``` |
| 44 | + |
| 45 | +Notes: |
| 46 | +- Replace `ACCESS_KEY` and `SECRET_KEY` with your AWS credentials |
| 47 | +- Replace `REGION` with your AWS region (e.g., us-east-1) |
| 48 | +- For SMTP, use the credentials generated in the Amazon SES console |
| 49 | + |
| 50 | +### 3. Mailchimp Transactional (Mandrill) |
| 51 | + |
| 52 | +To use Mailchimp Transactional (formerly Mandrill): |
| 53 | + |
| 54 | +``` |
| 55 | +MAILER_DSN=mandrill://API_KEY@default |
| 56 | +``` |
| 57 | + |
| 58 | +Notes: |
| 59 | +- Replace `API_KEY` with your Mailchimp Transactional API key |
| 60 | +- You can find your API key in the Mailchimp Transactional (Mandrill) dashboard |
| 61 | + |
| 62 | +### 4. SendGrid |
| 63 | + |
| 64 | +To use SendGrid: |
| 65 | + |
| 66 | +``` |
| 67 | +# Using API |
| 68 | +MAILER_DSN=sendgrid://API_KEY@default |
| 69 | +
|
| 70 | +# Using SMTP |
| 71 | +MAILER_DSN=smtp://apikey:[email protected]:587 |
| 72 | +``` |
| 73 | + |
| 74 | +Notes: |
| 75 | +- Replace `API_KEY` with your SendGrid API key |
| 76 | +- For SMTP, the username is literally "apikey" and the password is your actual API key |
| 77 | + |
| 78 | +## Testing Your Configuration |
| 79 | + |
| 80 | +After setting up your preferred mailer transport, you can test it using the built-in test command: |
| 81 | + |
| 82 | +```bash |
| 83 | +bin/console app:send-test-email [email protected] |
| 84 | +``` |
| 85 | + |
| 86 | +## Switching Between Transports |
| 87 | + |
| 88 | +You can easily switch between different mailer transports by changing the `MAILER_DSN` environment variable. This can be done in several ways: |
| 89 | + |
| 90 | +1. Edit the `config/parameters.yml` file directly |
| 91 | +2. Set the environment variable in your server configuration |
| 92 | +3. Set the environment variable before running a command: |
| 93 | + ```bash |
| 94 | + MAILER_DSN=sendgrid://API_KEY@default bin/console app:send-test-email [email protected] |
| 95 | + ``` |
| 96 | + |
| 97 | +## Additional Configuration |
| 98 | + |
| 99 | +Some transports may require additional configuration options. Refer to the Symfony documentation for more details: |
| 100 | + |
| 101 | +- [Symfony Mailer Documentation](https://symfony.com/doc/current/mailer.html) |
| 102 | +- [Gmail Transport](https://symfony.com/doc/current/mailer.html#using-gmail-to-send-emails) |
| 103 | +- [Amazon SES Transport](https://symfony.com/doc/current/mailer.html#using-amazon-ses) |
| 104 | +- [Mailchimp Transport](https://symfony.com/doc/current/mailer.html#using-mailchimp) |
| 105 | +- [SendGrid Transport](https://symfony.com/doc/current/mailer.html#using-sendgrid) |
0 commit comments