1

I'm trying to send an email with an inline image using Python/Django.

Here is the code showing how I am doing it. It's still in development. So all it is meant to do for now is send a dummy email message with a picture of a bumble bee embedded in it.

Yet when I receive the email in my Gmail inbox, I see only the following text-based email. The various Mime parts of the email show up in the payload of the email as text. I clicked the forward button and cut-n-pasted the entire email below so you can see what I get.

Can someone suggest what I'm doing wrong here? And a possible solution?

From: myApplication <donotrespond@mywebsite.com>
Date: Tue, Feb 18, 2014 at 1:39 AM
Subject: Hello World
To: myemail@gmail.com


Content-Type: multipart/related;
 boundary="===============5170682983005376168=="
MIME-Version: 1.0

--===============5170682983005376168==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<p>Hello <img src="cid:myimage" /></p>
--===============5170682983005376168==
Content-Type: image/jpeg
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Id: <myimage>

iVBORw0KGgoAAAANSUhEUgAABSsAAAV1CAYAAAD0tpuiAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2d
lndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji
1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE

<VERY LARGE PORTION SNIPPED>

BAgQIECAAIGaAsLKmnPVFQECBAgQIECAAAECBAgQIECAAIF0AsLKdCNTMAECBAgQIECAAAECBAgQ
IECAAIGaAsLKmnPVFQECBAgQIECAAAECBAgQIECAAIF0Av8HNFl0J1BnG68AAAAASUVORK5CYII=
--===============5170682983005376168==--
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
  • Where are you seeing this email? In the console? – zsquare Feb 18 '14 at 07:19
  • I'm seeing this email in my Gmail Inbox come out looking like this. I clicked "Forward" and cut-n-pasted the result to clearly show the issue. – Saqib Ali Feb 18 '14 at 07:33
  • You're saying "nearly the exact same thing verbatim". Care to share the code to see where the "nearly" comes in? Hard to tell what might have gone wrong without the code. – Sahand Feb 18 '14 at 07:50
  • 1
    This is precisely what I'm doing: https://gist.github.com/syedsaqibali/9066627 – Saqib Ali Feb 18 '14 at 08:12
  • Please post the relevant code snippet here, such that this question will be more useful for future reference on this site. – moooeeeep Feb 18 '14 at 08:21
  • @SaqibAli: Could you also click on the arrow symbol next to "Reply" in GMail and then click "Show Original" to see the raw source of the email and post it? That will be very helpful too. – Sahand Feb 18 '14 at 08:27
  • Shahand, I have posted that detail in a repost of this question here: http://stackoverflow.com/questions/21861593/how-can-i-send-inline-images-in-email-with-python-django moooeeeep, that information is already posted in the link in my question. – Saqib Ali Feb 18 '14 at 17:52
  • @SaqibAli: You shouldn't repost questions-- that will just cause confusion. You can (and should) always edit your own question. Be patient and answer questions/clarification requests in your original question and it will get an answer. – Platinum Azure Feb 18 '14 at 19:27
  • Let me rephrase. If you want people to take a look on your code on this site, you should post the relevant section of your code to this site. – moooeeeep Feb 18 '14 at 19:58
  • @PlatinumAzure that's not true. My repost got an answer. This question didn't. I win. – Saqib Ali Feb 18 '14 at 23:10
  • @moooeeeep What difference does it make where I post the code? If I posted a ton of code and output here, the question would be unreadable. It would be a lot more helpful if you simply answered the question. If not, you can just ignore it and move on. – Saqib Ali Feb 18 '14 at 23:15

0 Answers0