[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: to mail attachment using #mail command



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 1 Oct 2001, Moke wrote:
>I wanted to do a cron service to sent an attachement to a certain email
>account but #mail doesn't seem to have an attachemnt flag.
>
>Do anyone have any idea of doing that ? ?

Uuencode will work depending on the recipient's mailer. If you eally need
a MIME attachment, here's a script that will do the trick:

#!/bin/bash
#
# Script: sendfile
#
# Purpose: Send the specified file via email as a MIME 
#          attachment to the specified address.
#
# Author: Anthony E. Greene <agreene pobox com>
#
# License: GPL <http://www.gnu.org/>
#
# Note: This script does not include any error checking, so
#       it should only be called from within other scripts.
#       The correct syntax for using this script is:
#
# sendfile.sh user domain filename | /path/to/sendmail -oi -t
#

# First we set up some global variables.
# Some code should be added to verify the commandline arguments.
sender=me myisp domain
recipient=$1
filename=$2
basefile=`/bin/basename $filename`

echo From: $sender
echo To: $recipient
echo Subject: File $basefile
echo MIME-Version: 1.0
echo "Content-Type: multipart/mixed; Boundary=\"sendfile-attachment-boundary\""
echo
echo --sendfile-attachment-boundary
echo 'Content-Type: text/plain; charset=us-ascii'
echo
echo This is a MIME encoded message. If your mail software
echo cannot properly handle the attached file, you may need
echo to get a MIME-aware mailer.
echo
echo --sendfile-attachment-boundary
echo "Content-Type: application/octet-stream; name=\"$basefile\""
echo Content-Transfer-Encoding: base64
echo "Content-Disposition: attachment; filename=\"$basefile\""
echo
/usr/bin/mimencode $filename
echo --sendfile-attachment-boundary--

- -- 
Anthony E. Greene <agreene pobox com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26  C484 A42A 60DD 6C94 239D
Chat:  AOL/Yahoo: TonyG05
Linux. The choice of a GNU Generation. <http://www.linux.org/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Anthony E. Greene <agreene pobox com> 0x6C94329D

iD8DBQE7uFWRpCpg3WyUI50RAodZAJ9klrMU5vguYUZUJl4wvPmyYiJSbwCg3BGK
BwdeAty/+JxcNT/FtCgMUwI=
=jwBQ
-----END PGP SIGNATURE-----






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]