index.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. .. meta::
  2. :description: Red Mail is an advanced email sender for Python. It is open source and well tested.
  3. :keywords: send, email, Python
  4. .. raw:: html
  5. :file: header.html
  6. - `Documentation <https://redbox.readthedocs.io/>`_
  7. - `Source code (Github) <https://github.com/Miksus/red-mail>`_
  8. - `Releases (PyPI) <https://pypi.org/project/redbox/>`_
  9. This is a sister library for `Red Box, advanced email reader <https://red-box.readthedocs.io/>`_.
  10. Red Mail is a Python library for sending emails.
  11. It makes sending emails very trivial regardless of whether
  12. you need to embed images, plots, tables or
  13. attach documents. It also provides you convenient
  14. templating options and it is easy to create email alerts,
  15. email reports or client notifications with it.
  16. Visit the `source code from Github <https://github.com/Miksus/red-mail>`_
  17. or `releases in Pypi page <https://pypi.org/project/redmail/>`_.
  18. Why Red Mail?
  19. -------------
  20. Sending emails is a pretty straight forward task.
  21. However, the SMTP and email libraries from the standard library
  22. don't make it particularly easy.
  23. Sending emails **SHOULD NOT** look like this:
  24. .. code-block:: python
  25. import smtplib
  26. from email.mime.multipart import MIMEMultipart
  27. from email.mime.text import MIMEText
  28. msg = MIMEMultipart('alternative')
  29. msg['Subject'] = 'An example email'
  30. msg['From'] = 'me@example.com'
  31. msg['To'] = 'you@example.com'
  32. part1 = MIMEText("Hello!", 'plain')
  33. part2 = MIMEText("<h1>Hello!</h1>", 'html')
  34. msg.attach(part1)
  35. msg.attach(part2)
  36. # Send the message via our own SMTP server.
  37. s = smtplib.SMTP('localhost', port=0)
  38. s.send_message(msg)
  39. s.quit()
  40. It should look like this:
  41. .. code-block:: python
  42. from redmail import EmailSender
  43. email = EmailSender(host="localhost", port=0)
  44. email.send(
  45. subject="An example email",
  46. sender="me@example.com",
  47. receivers=['you@example.com'],
  48. text="Hello!",
  49. html="<h1>Hello!</h1>"
  50. )
  51. There are also other reasons to use Red Mail:
  52. - :ref:`You can put attachments to the email <attachments>`
  53. - :ref:`You can include images to the body <embedding-images>`
  54. - :ref:`You can render nicer tables to the body <embedding-tables>`
  55. - :ref:`It has Jinja support <jinja-support>`
  56. - :ref:`You can reuse your HTML templates <templating>`
  57. - :ref:`Gmail <config-gmail>` and :ref:`Outlook <config-outlook>` pre-configured
  58. - :ref:`Send with cc and bcc <send-cc-bcc>`
  59. - :ref:`Change the email protocol to what you need <config-smtp>`
  60. - :ref:`Easy to use logging handler <ext-logging>`
  61. - :ref:`Easy to use Flask extension <ext-flask>`
  62. - And it is well tested and documented
  63. More Examples
  64. -------------
  65. Interested in more?
  66. Here are some more quick examples:
  67. - :ref:`examples-simple`
  68. - :ref:`examples-attachments`
  69. - :ref:`examples-embed-image`
  70. - :ref:`examples-embed-plot`
  71. - :ref:`examples-embed-table`
  72. - :ref:`examples-parametrized`
  73. - :ref:`examples-mega`
  74. Interested?
  75. -----------
  76. Install the package:
  77. .. code-block:: console
  78. pip install redmail
  79. Some more practical examples:
  80. - :ref:`cookbook-campaign`
  81. - :ref:`cookbook-alerts`
  82. - :ref:`cookbook-stats`
  83. .. toctree::
  84. :maxdepth: 2
  85. :caption: Contents:
  86. tutorials/index
  87. extensions/index
  88. references
  89. faq
  90. versions
  91. Indices and tables
  92. ==================
  93. * :ref:`genindex`