Skip to content

Instantly share code, notes, and snippets.

@zhaoz
Created January 4, 2011 08:40
Show Gist options
  • Save zhaoz/764545 to your computer and use it in GitHub Desktop.
Save zhaoz/764545 to your computer and use it in GitHub Desktop.
emailer
#!/bin/bash
FILENAME=$1
if [ -z "$FILENAME" ]; then
echo "First argument must by file of emails and names"
exit 1
fi
FROM="Xing Yi <xingyi@u.washington.edu>"
SUBJECT="CHANGE ME TO SOMETHING"
env > outenv
cat $FILENAME | while read input; do
addr=`echo $input | awk -F, '{print $1;}'`
fname=`echo $input | awk -F, '{print $2;}'`
read -d '' email <<EOSTUFF
To: $fname <$addr>
From: $FROM
Subject: $SUBJECT
hey $fname, we gotta do stuff.
EOSTUFF
echo "$email"
echo "$email" | sendmail -i $addr
if test $? -ne 0 ; then
echo "ERROR SENDING EMAIL"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment