#!/bin/sh
export MAILTO="$1"
export SUBJECT="$2"
export BODY=""
export ATTACH="$3"
(
echo "To: $MAILTO"
echo "From: from@domain.com"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo
echo '---q1w2e3r4t5'
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
echo ""
#cat $BODY
echo "Email Body Here"
echo ""
echo '---q1w2e3r4t5'
echo 'Content-Disposition: inline; filename="'$(basename $ATTACH)'"'
echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
echo "Content-Transfer-Encoding: base64"
echo ""
uuencode --base64 $ATTACH $(basename $ATTACH)
echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail -f from@domain.com $MAILTO
(you'll need to change the address from@domain.com)
called as follows:
./sendemail.sh to_user@domain.com "Subject" /tmp/file.pdf
No comments:
Post a Comment