config.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. Configuring for Different Providers
  2. ===================================
  3. .. _config-gmail:
  4. Gmail
  5. -----
  6. You need to make an application password `see this Google's answer <https://support.google.com/accounts/answer/185833>`_.
  7. You may also need to set up `2-step verification <https://support.google.com/accounts/answer/185839>`_ in order to
  8. be able to create an application password. Don't worry, those are easy things to configure.
  9. When you have your application password you can use Red Mail's gmail object that has the Gmail
  10. server pre-configured:
  11. .. code-block:: python
  12. from redmail import gmail
  13. gmail.user_name = 'example@gmail.com' # Your Gmail address
  14. gmail.password = '<APP PASSWORD>'
  15. # And then you can send emails
  16. gmail.send(
  17. subject="Example email",
  18. receivers=['example@gmail.com']
  19. text="Hi, this is an email."
  20. )
  21. .. note::
  22. You can only send emails using your Gmail email address. Changing ``sender`` has no effect.
  23. .. note::
  24. ``gmail`` is actually nothing more than an instance of :class:`redmail.EmailSender`
  25. with ``smtp.gmail.com`` as the host and ``587`` as the port.