Discussion:
[bug-mailutils] Can't send attachment and Html Body simultaneously
\\/[!]shal
2017-01-13 09:02:43 UTC
Permalink
Hi,

I can not send email with html body with attachment.
Command1:
echo "<html><b>Hello</b></html>" | mail -s "#1" -a "content-type:
text/html" ***@gmail.com
Command2:
echo "<html><b>Hello</b></html>" | mail -s "#2" -a "content-type:
text/html" ***@gmail.com -A "/Users/vishal/Downloads/00000001.pdf"

Command1 works fine. I see email with html body, but in 2nd command body is
in text format.

Please let me know if I am missing something here.

-Vishal
Sergey Poznyakoff
2017-01-14 12:08:38 UTC
Permalink
Post by \\/[!]shal
I can not send email with html body with attachment.
That's wrong. This command does not create an attachment at all, it
simply puts the supplied text in the body of the message.

If you wish to send that text as attachment, first save it to a
temporary file, and then attach it using the -A option:

echo "<html><b>Hello</b></html>" > 1.tmp
mail -s "#1" --content-type text/html -A 1.tmp \
***@gmail.com < /dev/null
rm 1.tmp

Note that the recent changes (commits eabddf8 to 63229086) make it
possible to avoid creation of the temporary. Using git HEAD, you can do
that in one line as follows:

echo "<html><b>Hello</b></html>" | \
mail -s "#1" --content-type text/html -A - \
Post by \\/[!]shal
Command1 works fine. I see email with html body, but in 2nd command body is
in text format.
I don't quite get what you mean by "command body". What's the intent of
Command2?

Regards,
Sergey

Loading...