Difference between revisions of "Sendmail from script"
From thelinuxwiki
Line 16: | Line 16: | ||
example #3 using mailx | example #3 using mailx | ||
− | echo "my test message body " | mail -s " | + | echo "my test message body " | mail -s "my subject" yourfriend@somewhere.com |
example #4 | example #4 |
Latest revision as of 14:42, 16 February 2014
how to send mail from a script on a mail server
example #1 using the postfix sendmail binary
echo "Subject: Testing" | cat - /var/tmp/test_message_body.txt | /usr/sbin/sendmail -F me@overhere.com you@overthere.com
or use \n to separate subject from message body
echo "Subject: Testing\nMessage body!" | /usr/sbin/sendmail -F me@overhere.com you@overthere.com
example #2 using the postfix sendmail binary
echo "Subject: Testing" | /usr/sbin/sendmail -F me@overhere.com you@overthere.com
example #3 using mailx
echo "my test message body " | mail -s "my subject" yourfriend@somewhere.com
example #4
mail -F me@overhere.com you@overthere.com < message.txt
where the contents of message.txt are:
SUBJECT:Testing some mail stuff
blah blah blah message text
.
- note mail is a link to sendmail