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

sending an attachment with *nix mail or mailx

Status
Not open for further replies.

Mark888

IS-IT--Management
Jul 7, 2003
4
NL
Does anybody know how to send an attachment with Unix mail or mailx?

Any help is appreciated.

Rgds,

Mark
 
I don't believe that mailx supports attachments. We ran into this last year and ended up installing PINE, which can be downloaded from (if you're running Solaris), but can also be found for just about any other *NIX.

Another solution could be to use the uuencode utility to "encode" your attachment as text and send it as the body of your message. The person at the receiving end of the message would have to uudecode or something similiar in order to use the file.

HTH

Jason
 
another alternative is too look for 'mpack' and 'munpack' on the web ... i downloaded them and compiled them in no time ... they worked well for me ...
 
uuencode name_of_attachment name_of_attachment | mailx email_address

for example i want to attach file me.jpg

uuencode me.jpg me.jpg | mailx joe@bloggs.com
 

i think installing PINE might do you some good it's plain and simple when you want to put attachments you just hut CTRL + J and then put the path to where your attachment is and press Enter pretty simple and painless !! :)
 
Here is a small application I wrote for you to send email with a subject, body text, and a plain text attachment using mailx.

clear
echo "Rob Mail Version 1.0"
echo " "
echo "Mail Utility To Send Email From Unix with Attachment"
echo " "
echo " "
echo "Press Enter To Continue..."
read NOTHING
rm new_mail 2>/dev/null
rm new_attach 2>/dev/null
echo "Enter email address of recipient..."
read TO_EMAIL
echo "To:" $TO_EMAIL > new_mail
echo "Enter Subject of email..."
read EMAIL_SUBJECT
echo "Subject:" $EMAIL_SUBJECT >> new_mail
echo "Mime-Version: 1.0" >> new_mail
echo "Content-Type: text/plain" >> new_mail
echo "Enter Body Text of email..."
read EMAIL_TEXT
echo $EMAIL_TEXT >> new_mail
echo "" >> new_mail
echo "Enter Plain Text File that you want attached..."
read ATTACH_FILE
uuencode $ATTACH_FILE $ATTACH_FILE > new_attach
cat new_attach >> new_mail
mailx -t < new_mail
rm new_mail
rm new_attach
 
you probably want a loop around EMAIL_TEXT, allowing it to stop inputting on a '.' or something, same as other mailers, possibly also want to allow more than one attachment.
 
I have posted 2 scripts in the FAQ of this forum, with some minor changes you can change it to suit your requirements. IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top