I'm using django.core.mail.EmailMultiAlternatives when sending e-mails from my django app in an attempt to make sure that the message downgrades to text if the e-mail client doesn't support HTML.
Here is my send_email method:
def send_email(self, from_address, to_list, subject, msg_text, msg_html):
subject=subject.replace('\r','').replace('\n',' ')
self.msg = EmailMultiAlternatives(subject, msg_text, from_address, to_list)
self.msg.attach_alternative(msg_html, "text/html")
self.msg.content_subtype = "html"
self.msg.send()
It works great with Gmail, Hotmail and many other e-mail clients - displaying the HTML content without a problem. But it will not display the HTML content in Outlook 2003 running on Win2003 - just the text version.
If I forcefully put the HTML in the EmailMultiAlternatives call, i.e. use msg_html instead of msg
_text like so:
self.msg = EmailMultiAlternatives(subject, msg_html, from_address, to_list)
then it works correctly in all clients; but that means that there is no text fallback for clients that don't support HTML or (more likely) that have disabled support for it.
I think it is worth mentioning that the e-mail is being generated on a django app running on Mac OS X (just in case it has to do with line terminator differences between the OSes).
I see that people using other languages have had similar problems with outlook...
I wonder if anyone has any idea of WHY outlook would behave differently and if there is simple fix that can be applied in my code?