drewr/postal

embedding attached images in html not working.

zendevil opened this issue · 3 comments

I am sending an email with this body:

:body [
{:type "text/html;charset=utf-8;"
                :content "<div> <img src=\"cid:file.png\"> <div>"
                }
{:type :attachment
                :content (java.io.File. "/path/to/file.png")}
]

My goal is to have the attached file.png be loaded as an image in the html. However, even though the attachment is being sent, the file isn't being loaded in the html. How do I fix this?

drewr commented

You have to actually set the Content-ID and then reference:

:body [{:type "text/html;charset=utf-8;"
        :content "<div> <img src=\"cid:somethingrandom\"> <div>"}
       {:type :attachment
        :content (java.io.File. "/path/to/file.png")
        :content-id "somethingrandom"}]

I didn't test this, and I don't know which clients you're working with. Eg, GMail might also depend on X-Attachment-ID.

What is X-Attachment-Id and an example please?

drewr commented

That's beyond the scope of postal. Give the suggestion a try and see if it works for you. You can reopen if you find a bug. Thanks!