Operating System - HP-UX
1831708 Members
2850 Online
110029 Solutions
New Discussion

Sendmail - Attaching Files to emails

 
SOLVED
Go to solution
Tim Hawk
Occasional Contributor

Sendmail - Attaching Files to emails

I want the ability to send files as attachments to emails. Does Sendmail have the capability to do this via a standard perl script? If so does anybody have a sample script?
7 REPLIES 7
Mark Greene_1
Honored Contributor

Re: Sendmail - Attaching Files to emails

don't use sendmail directly, use mailx with uuencode piped to it to attach the file. See the man page for uuencode for a syntax example.

HTH
mark
the future will be a lot like now, only later
Helen French
Honored Contributor

Re: Sendmail - Attaching Files to emails

Hi Tim,

Try this:

# uuencode attachment.txt attachment.txt | elm -s "subject" user@domain

OR

Check this out:

http://us-support.external.hp.com/cki/bin/doc.pl/sid=9bc3f3d11de098249e/screen=ckiDisplayDocument?docId=200000048039408

HTH,
Shiju

Life is a promise, fulfill it!
Robin Wakefield
Honored Contributor
Solution

Re: Sendmail - Attaching Files to emails

Hi Tim,

Here's a simple script using sendmail:

=======================================
#!/bin/ksh

if [ $# -ne 3 ] ; then
echo
echo Syntax error: $0 file subject recipient
echo
exit 1
fi

file=$1
subject=$2
recipient=$3

(echo "Subject: $2

Please find file $1 attached";
uuencode $file ${file}.txt) | /usr/lib/sendmail $recipient
=====================================

this sorts out the Subject, which sendmail expects to start "Subject: " followed by a blank line.

Rgds, Robin.
harry d brown jr
Honored Contributor

Re: Sendmail - Attaching Files to emails

For multiple files, use this:

for i in `echo filename1 filename2 filename3 ...`
do
uuencode $i $i.txt
done|mailx -m -s "test" username@whereever.com

Change ".txt" to the proper format, so if it's a pdf, and the original filename does snot end in .pdf, then change the above ".txt" to ".pdf".

live free or die
harry
Live Free or Die
Corthouts Carlo
Valued Contributor

Re: Sendmail - Attaching Files to emails

* ux2dos | uuencode | sendmail -v


* ux2dos | uuencode | mailx -s
Rita C Workman
Honored Contributor

Re: Sendmail - Attaching Files to emails

And just so you have more options than uuencode..

Here's a thread with a couple more ways to send attachments:

http://my1.itrc.hp.com/cm/QuestionAnswer/1,,0x41950559ff7cd4118fef0090279cd0f9!0,00.html

Regards,
Rita
charudatta
Occasional Advisor

Re: Sendmail - Attaching Files to emails

hi,
best and simple way to sebd ab attachment is using 'mpack'
mpack is available free on the net
easy to install and use
mpck -s"test" xyz@company.com file1 file2 ...
RTFM