sending.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .. _sending-emails:
  2. Sending Emails
  3. ==============
  4. This section covers the basics of sending emails.
  5. We use an ``EmailSender`` configured in :ref:`configure`.
  6. Sending Email with Text Body
  7. ----------------------------
  8. To send an email with plain text message:
  9. .. code-block:: python
  10. email.send(
  11. subject='email subject',
  12. receivers=['first.last@example.com'],
  13. text="Hi, this is an email."
  14. )
  15. Sending Email with HTML Body
  16. ----------------------------
  17. To send an email with html content:
  18. .. code-block:: python
  19. email.send(
  20. subject='email subject',
  21. receivers=['first.last@example.com'],
  22. html="""
  23. <h1>Hi,</h1>
  24. <p>this is an email.</p>
  25. """
  26. )
  27. Sending Email with text and HTML Body
  28. -------------------------------------
  29. You can also include both to your email:
  30. .. code-block:: python
  31. email.send(
  32. subject='email subject',
  33. receivers=['first.last@example.com'],
  34. text="Hi, this is an email.",
  35. html="""
  36. <h1>Hi,</h1>
  37. <p>this is an email.</p>
  38. """
  39. )