faq.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Frequently Asked Questions
  2. ==========================
  3. Circular Import
  4. ---------------
  5. **Question**
  6. I get this error:
  7. .. code-block:: console
  8. Traceback (most recent call last):
  9. File "..\email.py", line 1, in <module>
  10. from redmail import EmailSender
  11. File "..\redmail\__init__.py", line 1, in <module>
  12. from .email.sender import EmailSender, send_email, gmail, outlook
  13. File "..\redmail\email\__init__.py", line 1, in <module>
  14. from redmail.email.sender import EmailSender
  15. File "..\redmail\email\sender.py", line 3, in <module>
  16. from email.message import EmailMessage
  17. File "..\email.py", line 1, in <module>
  18. from redmail import EmailSender
  19. ImportError: cannot import name 'EmailSender' from partially initialized module 'redmail' (most likely due to a circular import) (..\redmail\__init__.py)
  20. **Answer**
  21. This is due to your script is named as ´´email.py´´ and that happens
  22. to be the same name as the email library from standard library.
  23. Please use another filename than *email.py*.
  24. From in Text Body
  25. -----------------
  26. **Question**
  27. In text body, a line starting with *From* gets turned to *>From*.
  28. For example, I have this code:
  29. .. code-block:: python
  30. from redmail import EmailSender
  31. email = EmailSender(...)
  32. email.send(
  33. subject="An example email",
  34. sender="me@example.com",
  35. receivers=['me@example.com'],
  36. text="Hi!\nFrom what we discussed..."
  37. )
  38. But email body looks like this:
  39. .. code-block:: console
  40. Hi!
  41. >From what we discussed...
  42. **Answer**
  43. Please use HTML body instead if this causes problems. This is a problem
  44. in smtplib itself and there is nothing to do with it at the moment.
  45. Line beginning with **From** is mangled to **>From** to avoid body
  46. injection and there is no way to switch that off. See more details from
  47. `this Stackoverflow answer <https://stackoverflow.com/a/71518593/13696660>`_.