@@ -37,9 +37,6 @@ environment variable in the ``.env`` file:
3737 # use this to disable email delivery
3838 MAILER_URL=null://localhost
3939
40- # use this to send emails via Gmail (don't use this in production)
41- MAILER_URL=gmail://username:password@localhost
42-
4340 # use this to configure a traditional SMTP server
4441 MAILER_URL=smtp://localhost:25? encryption=ssl& auth_mode=login& username=& password=
4542
@@ -107,15 +104,58 @@ The ``$message`` object supports many more options, such as including attachment
107104adding HTML content, and much more. Refer to the `Creating Messages `_ section
108105of the Swift Mailer documentation for more details.
109106
107+ .. _email-using-gmail :
108+
109+ Using Gmail to Send Emails
110+ --------------------------
111+
112+ During development, you might prefer to send emails using Gmail instead of
113+ setting up a regular SMTP server. To do that, update the ``MAILER_URL `` of your
114+ ``.env `` file to this:
115+
116+ .. code-block :: bash
117+
118+ # username is your full Gmail or Google Apps email address
119+ MAILER_URL=gmail://username:password@localhost
120+
121+ The ``gmail `` transport is simply a shortcut that uses the ``smtp `` transport,
122+ ``ssl `` encryption, ``login `` auth mode and ``smtp.gmail.com `` host. If your app
123+ uses other encryption or auth mode, you must override those values
124+ (:doc: `see mailer config reference </reference/configuration/swiftmailer >`):
125+
126+ .. code-block :: bash
127+
128+ # username is your full Gmail or Google Apps email address
129+ MAILER_URL=gmail://username:password@localhost? encryption=tls& auth_mode=oauth
130+
131+ If your Gmail account uses 2-Step-Verification, you must `generate an App password `_
132+ and use it as the value of the mailer password. You must also ensure that you
133+ `allow less secure apps to access your Gmail account `_.
134+
135+ Using Cloud Services to Send Emails
136+ -----------------------------------
137+
138+ Cloud mailing services are a popular option for companies that don't want to set
139+ up and maintain their own reliable mail servers. In Symfony apps, using these
140+ services is as simple as updating the value of ``MAILER_URL `` in the ``.env ``
141+ file. For example, for `Amazon SES `_ (Simple Email Service):
142+
143+ .. code-block :: bash
144+
145+ # The host will be different depending on your AWS zone
146+ # The username/password credentials are obtained from the Amazon SES console
147+ MAILER_URL=smtp://email-smtp.us-east-1.amazonaws.com:587? encryption=tls& username=YOUR_SES_USERNAME& password=YOUR_SES_PASSWORD
148+
149+ Use the same technique for other mail services, as most of the time there is
150+ nothing more to it than configuring an SMTP endpoint.
151+
110152Learn more
111153----------
112154
113155.. toctree ::
114156 :maxdepth: 1
115157
116158 email/dev_environment
117- email/gmail
118- email/cloud
119159 email/spool
120160 email/testing
121161
@@ -125,3 +165,5 @@ Learn more
125165.. _`Mandrill` : https://mandrill.com/
126166.. _`SendGrid` : https://sendgrid.com/
127167.. _`Amazon SES` : http://aws.amazon.com/ses/
168+ .. _`generate an App password` : https://support.google.com/accounts/answer/185833
169+ .. _`allow less secure apps to access your Gmail account` : https://support.google.com/accounts/answer/6010255
0 commit comments