This works:

echo "yada yada" | msmtp my@mail.com

but not this:

cat yadayada.txt | msmtp my@mail.com

which delivers the email with empty content.

Why does echo work through pipe but not cat with msmtp ?

  • Is your yadayada.txt formatted funny or have weird permissions? It works fine for me catting it out. – nerdwaller Aug 7 '13 at 21:52
  • yadayada.txt has u:rw g:rw o:r and is a multiline file. sample content: === rsync start === 2013-08-07 20:58:01 === rsync stop === 2013-08-07 21:00:50 – user19496 Aug 7 '13 at 21:56
  • this worked: tr -d ':' < yadayada.txt | msmtp my@mail.com – user19496 Aug 7 '13 at 22:26
  • ':' was the culprit. thx @nerdwaller you pointed me in the right direction. – user19496 Aug 7 '13 at 22:27
  • That makes sense, since msmtp allows uses of something like Subject: My subject line. Good catch! – nerdwaller Aug 7 '13 at 22:32

msmtp seems to rely on a wellformed email message in the file being read.


Subject: My subject line  
My body text

Since I don't care about Subject etc
(I'm sending an email when a logfile is modified using incron)

tr -d ':' < yadayada.txt | msmtp my@mail.com

is a Q&D way to get the logfile content sent using msmtp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.