[olug] email a binary file (uuencode no longer popular?)
Noel Leistad
noel at metc.net
Tue Aug 14 20:31:24 UTC 2007
never tried the uuencode thing, found this script which I sort of hacked
w/ vars to suit... $1 who, $2 what
i've made $3 the subject before, maybe someday, a here_doc for a little
verbage....
it's worked for me....
>>>>>>>>>>>>>>>>>>>>>>
!/bin/bash
###################################################
# The following is all you should have to modify #
# in order to get the script working for you. #
# This script presupposes that you have a #
# working sendmail on your system. An alias to #
# postfix or msmtp should work though. #
###################################################
from=sender at somewhere.dom
subject="Cron-Bash attachment email script"
msgdate=`date +"%a, %b %e %Y %T %z"` # Leave alone
boundary=GvXjxJ+pjyke8COw # Leave alone
archdate=`date +%F` # Leave alone
attachment=$2
archattachment="$2-${archdate}.txt"
emailtarget=$1
###################################################
# The text below Content-Disposition: inline can #
# be modified to suit your needs. It's #
# important that you escape all quotes in the #
# body of your message or the script will fail. #
###################################################
daemail=$(cat <<!
Date: $msgdate
From: $from
To: $emailtarget
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=\"$boundary\"
Content-Disposition: inline
--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
This is the text that makes up the body of the email.
Anything you want to appear in the body of the message
should be put here. Try to keep it generic since it\'s a
form email. Something along the lines of,
\"The results of xyz script has been attached to this
email.\"
--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=\"attachment.ext\"
!)
echo "$daemail" > msg.tmp
echo >> msg.tmp
cat "$attachment" >> msg.tmp
echo >> msg.tmp
echo "--$boundary--" >> msg.tmp
email=`cat msg.tmp`
echo "$email" | /usr/sbin/sendmail -t
rm msg.tmp
mv $attachment $archattachment
touch $attachment
>>>>>>>>>>>>>>>>
Jay Hannah wrote:
> For years I have done this:
>
> uuencode file.pdf file.pdf | mail jay at jays.net
>
> Recently it seems uuencode isn't on Linux machines by default any more.
> Is there some cooler way the crazy kids are doing this nowadays?
>
> Thanks,
>
> j
>
>
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
>
--
#######################################################
# Noel Leistad #
# #
#######################################################
Tao abides in non-action,
Yet nothing is left undone.
If kings and lords observed this,
The ten thousand things would develop naturally.
If they still desired to act,
They would return to the simplicity of formless substance.
Without for there is no desire.
Without desire there is.
And in this way all things would be at peace.
More information about the OLUG
mailing list