1

I'm having a issue with sendmail. I'm sending echo multiple text with sendmail (1 liner) but it isn't breaking up the line.

my code is like this:

$ echo "$text1\n$text2\n$text3\n$text4 | mail -s "subject" myemail 

But somehow it just doesn't break the line, any tips?

3
  • Use echo -e "$text1\n$text2\n$text3\n$text4" | mail -s "subject" myemail Commented Sep 16, 2014 at 10:11
  • echo -e didnt work, in my mail as output it showed "-e" before my text. Commented Sep 16, 2014 at 10:26
  • You must have put -e inside quotes… I using it a lot. Works for 100%! Commented Sep 16, 2014 at 10:42

1 Answer 1

1

Try this:

 $ printf "$text1\n$text2\n$text3\n$text4" | mail -s "subject" myemail 

NOTE: (assuming no % in $text)

You can also do it like this too:

$ (echo $text1 ;echo $text2 ;echo $text3 ;echo $text4 ) | \ mail -s "subject" myemail 

This last one creates a sub-shell with the parens wrapping the output of all the echo's. That output is then piped to the mail command.

1
  • arche, you are a hero, it worked. you helped me so often. thanks man. Commented Sep 16, 2014 at 10:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.