When I run:
echo "Subject: mysubject\n\nmytext" | sudo ssmtp myemail@gmail.com
I expect the line above to send an email to myemail@gmail.com with mysubject as Subject, and mytext as body of the email.
However, it sends an email with mysubject\n\nmytext
as Subject.
sudo ssmtp myemail@gmail.com <<<$"Subject: TESTING\n\nBody: of the email. TEST."
has the same problem (that is, packages the whole text as Subject.)
What's wrong? The lines above seem to work for others.
ssmtp
, but had a similar issue withsendemail
(note the E). Had to convert subject and body with Base64 to get new lines through. Dont forget to set theContent-Transfer-Encoding: base64
. – jc__ Apr 30 '18 at 13:36echo
does not do anything special with\n
unless (wildly unportable) flags are strewn into to the mix. Try insteadprintf(1)
or better yet usemail(1)
ormutt(1)
. – thrig Apr 30 '18 at 13:57printf "Subject: mysubject\n\nmytext" | sudo ssmtp myemail@gmail.com
instead ofecho ...
works. Thanks – Pierre B Apr 30 '18 at 16:12