I am trying to embed images inside an email.
The email is created by sending data via a socket to a SMTP server on port 25. Here's the MIME bit:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=mixedsection;
--mixedsection
Content-Type: text/plain;
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Below should be an inline embedded image
--mixedsection
Content-Type: image/png; file=ts-charts.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=ts-charts.png
iVBORw0KGgoAAAANSUhEUgAAAnoAAAHqCAMAAACk+hPgAAABpFBMVEX// (etc etc etc)
--mixedsection--
When the email is received, it appears that the second section, the image, is converted into an attachment and never displayed inline. All of the other parts work fine, the image is correctly encoded as base64 so the attachment can be opened. The text/plain part works correctly both when the Content-Disposition is set to inline or attachment.
I've used other mail clients (outlook, thunderbird) to embed the image, and no problem with the image being displayed inline.
I can't even get the image to display inline even if I strip away everything else. The following is still received as an attachment:
MIME-Version: 1.0
Content-Type: image/png; file=ts-charts.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=ts-charts.png
iVBORw0KGgoAAAANSUhEUgAAAnoAAAHqCAMAAAC (etc etc)
So the question is, what am I missing here, and how do I get the image to display inline?