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

Try using echo -e

echo -e "Hello \n World"

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


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]

Tested on MacOS with Bash 3.2

bash-3.2$ mail -s "$subject" [email protected] <<< $(printf "%s\r\n%s\n" "This is Line One"  "This is Line Two")

This is a screen shot from gmail of the email received

enter image description here


The accepted answer did not work for me when using the mail command, I had to use

\r

My whole command is

mail -s "SUBJECT" -aFrom:"[email protected] "[email protected]" <<< $( echo -e "Line1\rLine2")