Search code examples
pythonemailsendmailpylonsembedding

TurboMail not adding Content-ID when embedding images


My bad. Postmark does not support inline images apparently. Solved by changing smtp-mail provider.

I'm trying to send e-mails with TurboMail using pylons.

Everything works fine, except for using embedded images in html-content. It seems that the Content-ID header for each image is being lost somewhere along the way.

This is my code:

def sendMail(to,subject,html_content,plain_content,images):
    from turbomail import Message as Mail
    mail = Mail(to=to,subject=subject)
    mail.plain = plain_content
    mail.rich = html_content

    for cid,path in images.iteritems():
        mail.embed(path,cid)

    mail.send()

In my tests the html content is:

<html>
  <header/>
  <body>
  <h1>Send images using TurboMail</h1>
  <img src="cid:img0" />
 </body>
</html>

And the images dict:

{"img0":"path/to/img0"}

Solution

  • Apparently, Postmarkapp does not support inline images.