diff --git a/cookbook/email/gmail.rst b/cookbook/email/gmail.rst index 9f925cad224..c6fbcbd1b04 100644 --- a/cookbook/email/gmail.rst +++ b/cookbook/email/gmail.rst @@ -8,11 +8,6 @@ During development, instead of using a regular SMTP server to send emails, you might find using Gmail easier and more practical. The SwiftmailerBundle makes it really easy. -.. tip:: - - Instead of using your regular Gmail account, it's of course recommended - that you create a special account. - In the development configuration file, change the ``transport`` setting to ``gmail`` and set the ``username`` and ``password`` to the Google credentials: @@ -55,33 +50,84 @@ In the development configuration file, change the ``transport`` setting to 'password' => 'your_gmail_password', )); -You're done! +If you are using the Symfony Standard Edition, it's more convenient to configure +these options in the ``parameters.yml.dist`` file: -.. tip:: +.. code-block:: yaml - If you are using the Symfony Standard Edition, configure the parameters in ``parameters.yml``: + # app/config/parameters.yml.dist + parameters: + # ... + mailer_user: your_gmail_username + mailer_password: your_gmail_password + +.. configuration-block:: .. code-block:: yaml - # app/config/parameters.yml - parameters: - # ... - mailer_transport: gmail - mailer_host: ~ - mailer_user: your_gmail_username - mailer_password: your_gmail_password + # app/config/config_dev.yml + swiftmailer: + transport: gmail + username: '%mailer_user%' + password: '%mailer_password%' + + .. code-block:: xml + + + + + + + + + + .. code-block:: php + + // app/config/config_dev.php + $container->loadFromExtension('swiftmailer', array( + 'transport' => 'gmail', + 'username' => '%mailer_user%', + 'password' => '%mailer_password%', + )); + +Redefining the Default Configuration Parameters +----------------------------------------------- + +The ``gmail`` transport is simply a shortcut that uses the ``smtp`` transport +and sets these options: + +============== ================== +Option Value +============== ================== +``encryption`` ``ssl`` +``auth_mode`` ``login`` +``host`` ``smtp.gmail.com`` +============== ================== + +If your application uses ``tls`` encryption or ``oauth`` authentication, you +must override the default options by defining the ``encryption`` and ``auth_mode`` +parameters. -.. note:: +If you are using 2-Step-Verification, you must `generate an App password`_ and +use this as your ``mailer_password`` value. - The ``gmail`` transport is simply a shortcut that uses the ``smtp`` transport - and sets ``encryption``, ``auth_mode`` and ``host`` to work with Gmail. +If your Gmail account uses 2-Step-Verification, you must `generate an App password`_ +and use it as the value of the ``mailer_password`` parameter. You must also ensure +that you `allow less secure apps to access your Gmail account`_. -.. note:: +.. seealso:: - Depending on your Gmail account settings, you may get authentication errors - within your app. If your Gmail account uses 2-Step-Verification, you should - `generate an App password`_ to use for your ``mailer_password`` parameter. - You should also ensure that you `allow less secure apps to access your Gmail account`_. + :doc:`Swiftmailer configuration reference ` .. _`generate an App password`: https://support.google.com/accounts/answer/185833 .. _`allow less secure apps to access your Gmail account`: https://support.google.com/accounts/answer/6010255