How do I send this email in Python, opening files and stuff?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-05-19T21:50:03Z Indexed on 2010/05/19 22:00 UTC
Read the original article Hit count: 107

Filed under:
|
|
|
|
msg = EmailMessage(subject, body, from_email, [to_email])
msg.content_subtype = "html"
msg.send()

This is how I send an email in Django.

But what if I want to open a text file and take into account all its line breaks and tabs. I want to take the body of the text file (with line breaks \n) and email it as text of the "body".

© Stack Overflow or respective owner

Related posts about python

Related posts about email