0

I'm using http://code.google.com/p/django-email-extras/ to generate rich email content. I have trouble in sending email with image included.

I put this line in my template

<img border="0" src="{{ image.url }}">

Sending email python script

# put everything to dictionary
dict = {'image': image,}
# send email 
send_mail_template(subject, 'confirm', '', request.user.email, fail_silently=False, attachments=None, context=dict)

I'm very sure {{ image.url }} is correct. I don't know why the image wasn't shown in the email, absolutely I activated "Display image" in my mailbox.

Please help me.

Quan
  • 473
  • 7
  • 16
  • 1
    you're going to have to provide a little more info. What does your email sending script look like? – Daniel Nill Nov 09 '11 at 03:54
  • hi Daniel, I edited my question. Thanks for your consideration. – Quan Nov 09 '11 at 03:59
  • 1
    what does your output look like if you set `EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'` in settings and run your script from the command line? – Daniel Nill Nov 09 '11 at 06:04

1 Answers1

0

{{ image.url }} will most likely return something like

/site_media/media/mypicture.jpeg This is not sufficient. For emails you need to include the domain address also.

What does the raw html look like in the email? The src url should be similar to "http://www.mydomain.com/{{image.url}}/ " in the document.

mtnpaul
  • 686
  • 4
  • 13
  • Thanks, it's working. According to this article http://stackoverflow.com/questions/1451138/how-can-i-get-the-domain-name-of-my-site-within-a-django-template I can get the domain name but I have to put " http:// " before domain name to make it work – Quan Nov 10 '11 at 08:46