I want to attach an image in email body using the mail
or mailx
from shell script. mutt
and sendmail
utilities is not available and I dont have privileges to install those.
uuencode
is also not available
First I tried sending the HTML content using mailx using the below command and it didnt work. It just send the raw data with html tags to the mail
export body="<html><header><title>This is title</title></header><body>Hello world</body></html>"
echo $body | mailx -S "MIME-Version: 1.0" -S "Content-Type: text/html" -vvv -s "test mail" -r sender@xx.com reciever@yy.com
I tried append-headers with the option -a and it didnt work since -a is meant for attachment
And also tried with below command and it just attaches the image and not visible in the body.
mailx -s "test mail" -r sender@xx.com reciever@yy.com < Capture.PNG
Can anyone help me with the correct way to send a email with picture in the body
发送附件的一种可能方法是使用如下命令:
uuencode Capture.PNG Capture.PNG|mailx -s "test mail" -r sender@xx.com reciever@yy.com
Simplest answer:
mail -s "the subject" -a attachment.xyz you@email.com < body.txt
If that doesn't work for you, use multipart MIME. cf this post on Stack Exchange for an example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.