sending.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. )
  40. .. _send-cc-bcc:
  41. Sending Email with cc and bcc
  42. -----------------------------
  43. You can also include carbon copy (cc) and blind carbon copy (bcc)
  44. to your emails:
  45. .. code-block:: python
  46. email.send(
  47. subject='email subject',
  48. receivers=['first.last@example.com'],
  49. cc=['also@example.com'],
  50. bcc=['outsider@example.com']
  51. )