1

I'm trying to use the following snippet:

http://djangosnippets.org/snippets/2661/#c4539

But I encountered some errors

1 ) i cannot import MIMEImage form email. I get an error: No module named MIMEImage

UPDATE: I had a file named email.py. Don't use file names that have the same name as Python standard library modules. Also don't forget to delete the hidden file named email.pyc in this case

2 ) I don't understand how to use this with Django's EmailMessage class. The following error shows: 'NoneType' object has no attribute 'body' when using:

from django.core.mail.message import EmailMessage
from emails import localize_html_email_images

mail = EmailMessage('Hoi', template, 'from@example.com', headers={'Reply-To': 'another@example.com'})
email = localize_html_email_images(mail

3 ) is this a good way to send html emails with images or are there other ways to do it (without installing other packages)?

What i'm trying to achieve is sending an activation email with a button to activate. The button has to be an image attached to the email.

nelsonvarela
  • 2,310
  • 7
  • 27
  • 43

2 Answers2

0

Send mail with html content: http://www.djangofoo.com/250/sending-html-email

TigorC
  • 534
  • 1
  • 6
  • 11
  • But what if you want to attach images for the email layout? And not aboslute links to the images but including the image as an attached file using multipart, Content-ID, etc – nelsonvarela Jul 11 '12 at 09:07
0

I think those links may help you : Creating email templates with Django

and : Easy Multi-Part E-Mails with Django

Community
  • 1
  • 1
HydrUra
  • 1,336
  • 2
  • 13
  • 23