Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert new line in the email using linux mail command? [duplicate]

how to insert new line in the email using linux mail command?

echo "Hi xxx, would you tell me something?\\n thanks!\\n -xxx" | mail -s "subject" [email protected]

The email shows the literal '\n', not a newline, how do fix it?

like image 831
user881480 Avatar asked Sep 03 '25 06:09

user881480


2 Answers

Try using echo -e

echo -e "Hello \n World"

You can type man echo from the command line to read more.

like image 186
jahroy Avatar answered Sep 04 '25 19:09

jahroy


With mailx, if you send the email to an Outlook user, you can add 2 spaces at the beginning of each line.

{ echo "Hi xxx, would you tell me something" ; echo "thanks!" ; echo "-xxx" } | sed 's/^/  /g' | mailx -s "subject" [email protected]
like image 22
Eric Avatar answered Sep 04 '25 18:09

Eric