itzforu
itzforu

Reputation: 115

send html content using mail command

I was trying to send an html file using mail commnad, but the mail contents alignment is not working.

Here is the command used to send the mail

/bin/mail -s "$(echo -e "log - $date\nFrom: ABC \n";)" [email protected] < /root/test

After searching, I found that we need to add "Content-Type" on the header. So I have added it on the header and its worked, but the From header is not working and some additional info showing on the mail.

Here is the command I used to send mail :

/bin/mail -s "$(echo -e "log - $datet\nContent-Type: text/html\nFrom: ABC \n";)" [email protected] < /root/test

The additional info showing on the mail while adding content-type is as follows : From: ABC User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable = =20

Could anyone please tell me how to send html using mail command with all the above options?

Upvotes: 0

Views: 3420

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328614

Use mutt instead. See this question: Send Html page As Email using "mutt"

This question how do what you want but you need a version of mail which supports adding headers: https://unix.stackexchange.com/questions/15405/how-do-i-send-html-email-using-linux-mail-command

If your Linux distro doesn't come with one, then download the sources for mailutils from http://mailutils.org/ and compile them. See this question: https://superuser.com/questions/243152/how-to-send-email-message-content-as-html-rather-than-plain-text

Upvotes: 0

Related Questions