#########################################
# send email with attachment out of KP #
#########################################
# Usage: mailout email@address
# or mailout email@address filename
#########################################
if [[ $# == 0 ]] then
echo argument number: $#
echo "Usage: mailout email@address filename"
echo " or: mailout email@address"
else
if [[ $# == 1 ]] then
SMTPserver="your.mail.server"
SMTPport=25
(
echo "helo your.unix.machine"
echo "MAIL From:
echo "RCPT To:<$1>"
echo "DATA"
echo "To: <$1>"
echo "From: Your Name
echo "Subject: your subject"
echo "your mail body"
echo "."
echo "quit"
) | /path/of/telnet $SMTPserver $SMTPport
else
SMTPserver="your.smtp.server"
SMTPport=25
(
echo "helo your.unix.machine"
echo "MAIL From:
echo "RCPT To:<$1>"
echo "DATA"
echo "To: <$1>"
echo "From: Your Name
echo "Subject: your_subject"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo
echo '---q1w2e3r4t5'
echo 'Content-Type: application; name="'$(basename $2)'"'
echo "Content-Transfer-Encoding: base64"
echo 'Content-Disposition: attachment; filename="'$(basename $2)'"'
uuencode -m $2 $(basename $2)
echo '---q1w2e3r4t5--'
echo "."
echo "quit"
) | /path/of/telnet $SMTPserver $SMTPport
fi
fi
No comments:
Post a Comment