I'm using GMail API to send a MIME email. The text part of the email always gets regenerated from the HTML part.
I have tried various variations in MIME and how I structure the headers. Another man reported the same problem a few years back:
Gmail API replaces text/plain alternative body part with automatically generated one from HTML
The message shows correctly in GMail interface "Sent" items, if I view the original of the message. However, the message arrives at the destination with text part replaced with HTML part. I tested it with several destinations, including Yahoo Mail.
The relevant part of the input multipart message is:
--0000000000d81f74059447a2ad02
Content-type: text/plain; charset=UTF-8
Hello plain text
--0000000000d81f74059447a2ad02
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<b>Hello html</b>
--0000000000d81f74059447a2ad02--
Viewing the raw message at the target (Yahoo Mail) shows this:
--00000000000046bd1105948482e9
Content-Type: multipart/alternative; boundary="00000000000046bd0e05948482e7"
--00000000000046bd0e05948482e7
Content-Type: text/plain; charset="UTF-8"
*Hello html*
--00000000000046bd0e05948482e7
Content-Type: text/html; charset="UTF-8"
<b>Hello html</b>
--00000000000046bd0e05948482e7--
Here's the full test case,
https://gist.github.com/borisreitman/448e2699c267221ebbf430b64346baaa
Notice that the text part now contains "Hello html" instead of the original "Hello plain text".