I developed a Django application to send emails to researchers in different universities and help them with their research. I tested the emails using Litmus and all emails passed all the tests and showed up completely in different platforms. Also I wanted to let those who have old browsers be able to see the contents of the emails. That's why I used EmailMultiAlternatives
to send both text content and the alternative html content. However, in one of the universities that I was testing the emails, everybody received incomplete emails. Also in another university, they received emails with broken lines. It was very problematic in case they saw broken hyperlinks.
The problem was related to 78 character limit in email lines explained in this Stackoverflow page.
However, in Django EmailMultiAlternatives
documentation, there is nothing about how to add headers like "format" or "Reply-To" in EmailMultiAlternatives
. It took a while for me to figure it out and I am sending this post to help others with saving their time.
As you can see in django's source code, EmailMultiAlternatives
inherits from EmailMessage, so they take the same parameters in the init constructor. This way, we can add headers like:
msg = EmailMultiAlternatives(subject, message, from_email, to_list, headers={'Reply-To': "email@example.com", 'format': 'flowed'})