No subject
Thu Apr 19 13:57:37 EDT 2007
Attached is the script I use.
You need to change the "From" address to your domain.
You may also need to change the content-type. I hard coded
"text/plain"
because that works for text and html attachments.
#!/bin/ksh
# attachmail by john julian Feb 26, 2002
Syntax='syntax: attachmail -a "attachmentname" -r "returnaddress" [ -s
"subject" ]
[ -m "message" ] recipient'
TempFile="/tmp/attachmail$$"
# get the command line args
while [ -n "$1" ]
do
case "$1" in
"-a" ) if [ -f "$2" ]
then
Attachment="$2"
shift 2
else
print "ERROR no attachment file"
exit
fi;;
"-r" ) From="$2"
shift 2
;;
"-s" ) Subject="$2"
shift 2
;;
"-m" ) Message="$2"
shift 2
;;
* ) Recipient="$Recipient $1"
shift
;;
esac
done
if [[ $Recipient != *@* ]]
then
print "ERROR invalid email address: $Recipient"
print "$Syntax"
exit
fi
if [ -z "$From" ]
then
From="$( whoami )@sbc.com"
fi
# put the headers in a temp file
print "Mime-Version: 1.0
To: $Recipient
Subject: $Subject
Content-Type: multipart/mixed; boundary=boundarystring
--boundarystring
Content-Type: text/plain
" > $TempFile
# if we have a message then add it to temp file
if [ -n "$Message" ]
then
print -- "$Message" >> $TempFile
fi
# add the attachment header
print -- "--boundarystring
Content-Type: text/plain
Content-Disposition: attachment; filename=$Attachment\n" >> $TempFile
# now the file itself
cat "$Attachment" >> $TempFile
print -- "--boundarystring--" >> $TempFile
/usr/lib/sendmail -f "$From" -t < $TempFile
/bin/rm $TempFile
-------------------------------------------------------------------------------
More information about the summaries
mailing list