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