Score:0

Send email from command line with an image in the body (not as attachment)

cn flag
SEU

I have a setup where I am sending an email using mailx with an attachment and that works OK. I am trying to send an email with the image in the body. Is there a way to do this - I tried several methods I found on google/stackoverflow, but the image is not shown.

ru flag
you need to also include it as an attachment for it to work proper, that's a limitation of mail.
Score:0
bs flag
knu

You will have to generate a multipart body resembling the raw mail below. This is how gmail composes such a message. I don't have a ready made script for you.

The Content-Type line is part of the mail headers, the rest is mail body.

Content-Type: multipart/related; boundary="00000000000065025f05f70a8645"

--00000000000065025f05f70a8645
Content-Type: multipart/alternative; boundary="00000000000065025c05f70a8644"

--00000000000065025c05f70a8644
Content-Type: text/plain; charset="UTF-8"

before
[image: favicon.png]
after

-- 
signature

--00000000000065025c05f70a8644
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>before</div><div><img src=3D"cid:ii_lfbkwr450" alt=3D=
"favicon.png" width=3D"64" height=3D"64"><br></div><div>after<br></div><div=
><br></div><div><div><div dir=3D"ltr">-- <br>signature</div></div></div></d=
iv>

--00000000000065025c05f70a8644--
--00000000000065025f05f70a8645
Content-Type: image/png; name="favicon.png"
Content-Disposition: inline; filename="favicon.png"
Content-Transfer-Encoding: base64
Content-ID: <ii_lfbkwr450>
X-Attachment-Id: ii_lfbkwr450

iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
[...some data removed...]
biBkAAAAAElFTkSuQmCC
--00000000000065025f05f70a8645--
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.