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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach files to an email

Status
Not open for further replies.

shine67

Programmer
Jan 11, 2002
41
US
Hi,

is there a unix command which I can use to attach, let's say, 5 files (one or more) to an email address? I don't want to send the content of the files as email message but as separate files as we do on MS Outlook on PC.

Thanks in advance,
Shine.
 
uuencode file-to-attach name-of-attachement | mailx -s "this is the subject" someone@somewhere.com

this will attach a single file, not sure about how to attach 5.

crowe
 
(uuencode $FILE1 $FILE1; uuencode $FILE2 $FILE2) | mail -s "$SUBJECT" $MAILTO

For multiple files within the message.

For attachments see
see the 'Bourne Shell Code' link on the above website for a way to hand craft multiple MIME attachments using a standard shell script
 
Wow! I just answered this same question in another forum. Here's how to send a bunch of attachments, including a nice little message...

If you have a bunch of files to be sent as attachments, you just uuencode them all. Say you have a directory full of files you want to send. Say they all end with the extension .txt. You would send them all in the same email as follows...
Code:
#!/bin/ksh

export TOADDR=name@email.com
export FROMDIR=/somedir

cd ${FROMDIR}

( cat <<-TEXT
Hi,

Please find enclosed all of the text files found
in the directory ${FROMDIR} as of $(date).

Sincerly, $(grep $(whoami) /etc/passwd| cut -d: -f5)
TEXT

for FNAME in *.txt
do
   uuencode ${FNAME} ${FNAME}
done
) | mailx -s &quot;${FROMDIR}/*.txt as of $(date)&quot; ${TOADDR}
This example exen gives a nice little message along with the email.

Hope this helps.

 
Hi Sam,

I have just used your script but I am getting the following messages, any ideas what it could be: -


The flags you gave are used only when sending mail.
Usage: mailx -eiIUdFntBNHvV~ -T FILE -u USER -h hops -r address
-s SUBJECT -f FILE users
uuencode: ISO8859-15 to 646 conversion: Invalid argument
# uuencode: ISO8859-15 to 646 conversion: Invalid argument
uuencode: ISO8859-15 to 646 conversion: Invalid argument
uuencode: ISO8859-15 to 646 conversion: Invalid argument
uuencode: ISO8859-15 to 646 conversion: Invalid argument


Hope you can help. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top