I am trying to send an email from Linux server, I want to send an image, not as an attachment, that should be displayed in the message body.
I tried.
mailx -s "TEST mail" <MASKED>@mask.com < download.JPEG
The above command gave a random junk data in the body of the mail
mailx --append "Content-type: text/html" -s "TEST mail" <MASKED>@mask.com < download.JPEG
The above command didn't work
mutt -a "download.JPEG" <MASKED>@mask.com -s "TEST mail" < /dev/null
The above command sent the image as an attachment.
UUENCODE
is not installed in our server, so we shouldn't use the same.
I don't want anyone of the above. I want my picture to be displayed on the body of my mail instead.
Any help on this is highly appreciated.
Best Answer
To get the picture to be displayed in-line, it must be encoded as a valid MIME object with a
Content-Disposition: inline
header in it.The
mpack
command can do this.Try sending an email like this:
Or if you want to output the result into a file instead of sending it directly:
Then you can send it later with e.g.:
If you want to add text to your message before the image, write it into a file, and add a
-d text-before.txt
option to thempack
command. For adding text after the image, just appending it to the mpack-produced file should work.