Thursday, September 20, 2012

Linux mail command using sendmail


mail.sh:
-------------------------------------------------------------
while read line
do
        if [ -n "`echo $line | grep \"#SUBJECT#\"`" ]
        then
                echo "Subject: message here" >> mail.txt
        elif [ -n "`echo $line | grep \"#CONTENT#\"`" ]
        then
                echo "content message here" >> mail.txt
        else
                echo $line >> mail.txt
        fi
done < mail_sample
sendmail -t -oi -f "sender@sender.com" < mail.txt
-------------------------------------------------------------

mail_sample:
----------------------------------------
From: sender@sender.com
To: receiver@receiver.com
Cc:  receiver@receiver.com
Content-type: text/html; charset=UTF-8
#SUBJECT#

#CONTENT#
----------------------------------------

No comments:

Post a Comment