getting_started.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .. meta::
  2. :description: Send email in Python.
  3. :keywords: send, email, Python
  4. .. _getting-started:
  5. Getting started
  6. ===============
  7. Install the package from `Pypi <https://pypi.org/project/redmail/>`_:
  8. .. code-block:: console
  9. pip install redmail
  10. .. _configure:
  11. Configuring Email
  12. -----------------
  13. You can configure your sender by:
  14. .. code-block:: python
  15. from redmail import EmailSender
  16. email = EmailSender(
  17. host='<SMTP HOST>',
  18. port='<SMTP PORT>',
  19. username='<USERNAME>',
  20. password='<PASSWORD>'
  21. )
  22. .. code-block:: python
  23. # Or if your SMTP server does not require credentials
  24. email = EmailSender(
  25. host='<SMTP HOST>',
  26. port='<SMTP PORT>',
  27. )
  28. There are guides to set up the following email providers:
  29. - :ref:`config-gmail`
  30. - :ref:`config-outlook`
  31. .. note::
  32. By default, Red Mail uses **STARTTLS** as the protocol.
  33. This is suitable for majority of cases but if you need
  34. to use **SSL**, **TLS** or other protocols, see :ref:`config-smtp`.
  35. Sending Emails
  36. --------------
  37. You can just send emails by calling the method ``send``:
  38. .. code-block:: python
  39. email.send(
  40. subject='email subject',
  41. sender="me@example.com",
  42. receivers=['you@example.com'],
  43. text="Hi, this is an email."
  44. )
  45. Next tutorial covers sending emails more thoroughly.