getting_started.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. Or install the package using Conda:
  11. .. code-block:: console
  12. conda install -c conda-forge redmail
  13. .. _configure:
  14. Configuring Email
  15. -----------------
  16. You can configure your sender by:
  17. .. code-block:: python
  18. from redmail import EmailSender
  19. email = EmailSender(
  20. host='<SMTP HOST>',
  21. port='<SMTP PORT>',
  22. username='<USERNAME>',
  23. password='<PASSWORD>'
  24. )
  25. .. code-block:: python
  26. # Or if your SMTP server does not require credentials
  27. email = EmailSender(
  28. host='<SMTP HOST>',
  29. port='<SMTP PORT>',
  30. )
  31. .. note::
  32. The correct SMTP port is typically 587.
  33. There are guides to set up the following email providers:
  34. - :ref:`config-gmail`
  35. - :ref:`config-outlook`
  36. .. note::
  37. By default, Red Mail uses **STARTTLS** as the protocol.
  38. This is suitable for majority of cases but if you need
  39. to use **SSL**, **TLS** or other protocols, see :ref:`config-smtp`.
  40. Sending Emails
  41. --------------
  42. You can just send emails by calling the method ``send``:
  43. .. code-block:: python
  44. email.send(
  45. subject='email subject',
  46. sender="me@example.com",
  47. receivers=['you@example.com'],
  48. text="Hi, this is an email."
  49. )
  50. Next tutorial covers sending emails more thoroughly.