0

I am sending email from the cmd with msmtp for that I do

cat > test1 << EOF
>From: "Tester"
>test
>EOF


cat test1 | msmtp email@mail.com

This works while:

echo -e 'From: "Tester"\ntest' > test2
cat test2 | msmtp email@mail.com

Doesn't work although

diff test1 test2 

returned nothing and both

 file -bi test1 test2 

returned the same results

 message/rfc822; charset=us-ascii
Nabil Sham
  • 267
  • 1
  • 2
  • 9
  • the new line \n isn't interprete with single quote – c4f4t0r Jun 08 '15 at 01:19
  • 1
    This has nothing to do with encoding and the diff should be returning something since the first cat would yield a two-line file while the echo command will only result in a one-liner. Either you've done something wrong or there is something you're not telling us. – cptMikky Jun 08 '15 at 01:24

1 Answers1

1

The problem is you're not using the -e option with your echo command.

Try this:

echo -e 'From: "Tester"\ntest' > test2
cat test2 | msmtp email@mail.com

-e is for telling echo to interpret escaped chars (like "\n").

moebius_eye
  • 1,092
  • 7
  • 21