Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Created September 11, 2012 20:08
Show Gist options
  • Save mikermcneil/3701644 to your computer and use it in GitHub Desktop.
Save mikermcneil/3701644 to your computer and use it in GitHub Desktop.
super simple mailer script
#!/usr/bin/ksh
#———————————————————————-
# Name: SendMail
# Purpose: To send mails using the sendmail command
# Usage: SendMail
# Owner: Ketan Joshi
# Setting: Just change the variables at the start of the script to
# appropriate values. Create a message by modifying the string BODY
# You can even have html tags in the body.
# Limitation: Currently, this does not support attachments.
#——————————————————————–
# Temporary file for containing the mail message
tmp=/tmp/mail-body-`date +%F`;
touch $tmp && chmod 600 $tmp;
# Set up the various headers for sendmail to use
TO='[email protected]';
CC='';
FROM='[email protected]';
SUBJECT='hey baby where you live?';
MIMEVersion='1.0';
CONTENTType="text/html; charset=us-ascii";
# Here write the content of your mail.
BODY="
<b>Hello from gabe.</b>
Time to party.
";
echo Sending the mail.
echo "To: $TO" > $tmp;
echo "Cc: $CC" >> $tmp;
echo "From: $FROM" >> $tmp;
echo "Content-Type: $CONTENTType">>$tmp;
echo "MIME-Version: $MIMEVersion">>$tmp;
echo "Subject: $SUBJECT">>$tmp;
echo "Body: $BODY">>$tmp;
/usr/sbin/sendmail -t < $tmp;
rm -rf $tmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment