1

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.

  • It is not recommended sending it in raw binary. I actually prefer mpack to uuencode. Install it. – Rui F Ribeiro Jun 5 '18 at 11:48
1

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:

mpack -s "TEST mail" -c image/jpeg download.JPEG <MASKED>@example.com

Or if you want to output the result into a file instead of sending it directly:

mpack -s "TEST mail" -c image/jpeg download.JPEG -o email-with-image.txt

Then you can send it later with e.g.:

mailx <MASKED>@example.com < email-with-image.txt

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 the mpack command. For adding text after the image, just appending it to the mpack-produced file should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.