getting_started.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. .. note::
  29. The correct SMTP port is typically 587.
  30. There are guides to set up the following email providers:
  31. - :ref:`config-gmail`
  32. - :ref:`config-outlook`
  33. .. note::
  34. By default, Red Mail uses **STARTTLS** as the protocol.
  35. This is suitable for majority of cases but if you need
  36. to use **SSL**, **TLS** or other protocols, see :ref:`config-smtp`.
  37. Sending Emails
  38. --------------
  39. You can just send emails by calling the method ``send``:
  40. .. code-block:: python
  41. email.send(
  42. subject='email subject',
  43. sender="me@example.com",
  44. receivers=['you@example.com'],
  45. text="Hi, this is an email."
  46. )
  47. Next tutorial covers sending emails more thoroughly.