email from bash script


Question

#!/bin/bash
MESSAGE="Line one. /n"

MESSAGE="$MESSAGE Line two. /n"
MESSAGE="$MESSAGE Line three."

echo $MESSAGE | mail -s "test" "example@example.com"

Is that how I should get each line, on its own line?

1
6
2/16/2010 8:07:31 PM

Use a heredoc.

mail -s "test" "example@example.com" << END_MAIL
Line one.
Line two.
Line three.
END_MAIL
14
2/16/2010 7:16:08 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon