@@ -8,11 +8,6 @@ During development, instead of using a regular SMTP server to send emails, you
88might find using Gmail easier and more practical. The SwiftmailerBundle makes
99it really easy.
1010
11- .. tip ::
12-
13- Instead of using your regular Gmail account, it's of course recommended
14- that you create a special account.
15-
1611In the development configuration file, change the ``transport `` setting to
1712``gmail `` and set the ``username `` and ``password `` to the Google credentials:
1813
@@ -55,33 +50,84 @@ In the development configuration file, change the ``transport`` setting to
5550 'password' => 'your_gmail_password',
5651 ));
5752
58- You're done!
53+ If you are using the Symfony Standard Edition, it's more convenient to configure
54+ these options in the ``parameters.yml.dist `` file:
5955
60- .. tip ::
56+ .. code-block :: yaml
6157
62- If you are using the Symfony Standard Edition, configure the parameters in ``parameters.yml ``:
58+ # app/config/parameters.yml.dist
59+ parameters :
60+ # ...
61+ mailer_user : your_gmail_username
62+ mailer_password : your_gmail_password
63+
64+ .. configuration-block ::
6365
6466 .. code-block :: yaml
6567
66- # app/config/parameters.yml
67- parameters :
68- # ...
69- mailer_transport : gmail
70- mailer_host : ~
71- mailer_user : your_gmail_username
72- mailer_password : your_gmail_password
68+ # app/config/config_dev.yml
69+ swiftmailer :
70+ transport : gmail
71+ username : ' %mailer_user%'
72+ password : ' %mailer_password%'
73+
74+ .. code-block :: xml
75+
76+ <!-- app/config/config_dev.xml -->
77+ <?xml version =" 1.0" encoding =" UTF-8" ?>
78+ <container xmlns =" http://symfony.com/schema/dic/services"
79+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
80+ xmlns : swiftmailer =" http://symfony.com/schema/dic/swiftmailer"
81+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
82+ http://symfony.com/schema/dic/services/services-1.0.xsd
83+ http://symfony.com/schema/dic/swiftmailer
84+ http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd" >
85+
86+ <!-- ... -->
87+ <swiftmailer : config
88+ transport =" gmail"
89+ username =" %mailer_user%"
90+ password =" %mailer_password%"
91+ />
92+ </container >
93+
94+ .. code-block :: php
95+
96+ // app/config/config_dev.php
97+ $container->loadFromExtension('swiftmailer', array(
98+ 'transport' => 'gmail',
99+ 'username' => '%mailer_user%',
100+ 'password' => '%mailer_password%',
101+ ));
102+
103+ Redefining the Default Configuration Parameters
104+ -----------------------------------------------
105+
106+ The ``gmail `` transport is simply a shortcut that uses the ``smtp `` transport
107+ and sets these options:
108+
109+ ============== ==================
110+ Option Value
111+ ============== ==================
112+ ``encryption `` ``ssl ``
113+ ``auth_mode `` ``login ``
114+ ``host `` ``smtp.gmail.com ``
115+ ============== ==================
116+
117+ If your application uses ``tls `` encryption or ``oauth `` authentication, you
118+ must override the default options by defining the ``encryption `` and ``auth_mode ``
119+ parameters.
73120
74- .. note ::
121+ If you are using 2-Step-Verification, you must `generate an App password `_ and
122+ use this as your ``mailer_password `` value.
75123
76- The ``gmail `` transport is simply a shortcut that uses the ``smtp `` transport
77- and sets ``encryption ``, ``auth_mode `` and ``host `` to work with Gmail.
124+ If your Gmail account uses 2-Step-Verification, you must `generate an App password `_
125+ and use it as the value of the ``mailer_password `` parameter. You must also ensure
126+ that you `allow less secure apps to access your Gmail account `_.
78127
79- .. note ::
128+ .. seealso ::
80129
81- Depending on your Gmail account settings, you may get authentication errors
82- within your app. If your Gmail account uses 2-Step-Verification, you should
83- `generate an App password `_ to use for your ``mailer_password `` parameter.
84- You should also ensure that you `allow less secure apps to access your Gmail account `_.
130+ :doc: `Swiftmailer configuration reference </reference/configuration/swiftmailer >`
85131
86132.. _`generate an App password` : https://support.google.com/accounts/answer/185833
87133.. _`allow less secure apps to access your Gmail account` : https://support.google.com/accounts/answer/6010255
0 commit comments