Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file attached in e-mail 2

Status
Not open for further replies.

sunboy

Technical User
Jan 30, 2002
6
0
0
CL
Hi,
How can I send an e-mail with a file attached in Unix?
(with "mail" command)

Thank

Sunboy
 
You need to use the "uuencode" program. It works fine.

Bill.
 
Well, you need to do more than that if you want it to really be an attachment- some MUA's will treat a uuencoded tackon as an attachment, but real attachments require more work. Freely available programs like "mutt" can generate true MIME attachments,

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
and for some definitive command line jiggerypokery:

uuencode attachment.txt attachment.txt|mail -s"subject matter" recipient@place.com

have fun ***************************************
Party on, dudes!
[cannon]
 
Karver,

How would you include some text in that email as well as the attachment? Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
echo "Hi there Ed
`date`
here is a text file:
`cat /tmp/file`
Here is the uuencoded stuff:
`uuencode attachment.txt attachment.txt`
"|mail -s"subject matter"

Note: one " on first line, one on last. None in betweeen.

BUT: as I said before, this is NOT actual attachments. For real MIME attachments from the command line you can use something like Mutt.

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Thx Tony Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Hi

You might try the following as well:
cat filename | mailx -s"subject" mail_address

George
 
Try this script, you may have to modify a bit to suit:


#!/bin/ksh
: '
sendattch.sh : Encapsulate standard input as a MIME attachment
and mail it to the correct destination.

ARGS: 1: Delivery address
2: File to send as attachment
'
ADDR=$1
FILE=$2
INTCHG=`basename $2 .txt`

USAGE="Usage: sendattch.sh delivery_address file_name"

TEMP=/tmp/$INTCHG.att

# Tidy-up Function

function doExit {
rm -f $TEMP
exit $1
}

# Validate arguments

[[ $# -eq 2 ]] || {
echo "Invalid number of arguments: $#\n$USAGE" >&2
doExit -1
}

# Construct the message

{
echo "To: $ADDR"
echo "Subject: $INTCHG"
echo "X-Priority: 3"
echo "MIME-Version: 1.0"
echo "Content-Type: application/msword;"
echo " name=\"$INTCHG.txt\""
echo "Content-Disposition: attachment;"
echo " filename=\"$INTCHG.txt\""
echo "Content-Description: $INTCHG"
echo
cat $FILE
} > $TEMP

# Send the constructed message

/usr/sbin/sendmail $ADDR < $TEMP
doExit $?
IBM Certified Specialist - MQSeries
IBM Certified Specialist - AIX 5 pSeries System Administration
 
aixmurderer,

Thank you for your neat and helpful script.

One vote from me.

Now I have to do some HP killing.


Regards Gregor Gregor.Weertman@mailcity.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top