Difference between revisions of "Sendmail from script"

From thelinuxwiki
Jump to: navigation, search
(Pushed from Themanclub.)

Revision as of 16:14, 24 May 2013

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 on panzer

    echo "my message body is that you are a gay homosexual pole smoking fag" | mail -s "what you are" 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