Hi,

I've had trouble sending multipart (plain+html) emails to Gmail users.
While emails are correctly displayed in any other email client, Gmail
displays the plain text version instead of the HTML, although the HTML
is set as primary.
After googling I think this is a known issue with Gmail, but I haven't
been able to find a work-around.

Have you come across that issue before, and would you know how to fix
that?

Below is my code.

Cheers!

Julien



from django.conf import settings
from django.core.mail import EmailMultiAlternatives, SMTPConnection

smtp_server='blabla'
smtp_user='blabla'
smtp_pass='blabla'


def html_mail(subject, recipient, html_contents, text_contents,
sender, recipient_name='', sender_name='', charset=None):
    from_email, to = named(sender, sender_name), named(recipient,
recipient_name)
    msg = EmailMultiAlternatives(subject, html_contents, from_email,
[to])
    msg.content_subtype = "html"  # Main content is now text/html
    msg.attach_alternative(text_contents, "text/plain")

    connection = SMTPConnection(host=smtp_server, username=smtp_user,
password=smtp_pass)
    connection.send_messages([msg])

def named(mail,name):
   if name: return '%s <%s>' % (name,mail)
   return mail



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to