Operating System - HP-UX
1752710 Members
5694 Online
108789 Solutions
New Discussion юеВ

Re: Using mailx to sned file as attachment

 

Using mailx to sned file as attachment

Hi ! Need help how can I send files as attachment using mailx?

Rgds.
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Using mailx to sned file as attachment

I don't know how to do it with mailx

I do have a very flexible script that does it with sendmail.

See attachment.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Tully
Honored Contributor

Re: Using mailx to sned file as attachment

This is how to send one or more:

$ for e in `echo file1 file2 file3`
do
uuencode $e $e.txt
done | mailx -m -s "mymail" username@domain.com

Make sure that you use the correct suffix for the file being used.
Anyone for a Mutiny ?
Hoefnix
Honored Contributor

Re: Using mailx to sned file as attachment

You can also do it within a script that also sends some output of other commands in between, like backup commands etc:{echo "start of email, with attaching a text file\n"ux2dos textfile1.txt | uuencode textfile1.txtecho "\n start of some command"echo "now send binary file\n"uuencode binaryfile1.bin binaryfile1.binecho "\n end of email, blabla...."}| mailx -m -s "mymail" username@domain.comHTH,Peter Geluk
Karthik S S
Honored Contributor

Re: Using mailx to sned file as attachment

Refer this link,

http://www.unixblog.com/quick_unix_tips/mailx_and_attachments.php

-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Hoefnix
Honored Contributor

Re: Using mailx to sned file as attachment

Just a new post to make preavious readable. The previous was messed up because I used Konqueror to post it.(Now mozilla)
************************************

You can also do it within a script that also sends some output of other commands in between, like backup commands etc:
{
echo "start of email, with attaching a text file\n"
ux2dos textfile1.txt | uuencode textfile1.txt
echo "\n start of some command"

echo "now send binary file\n"
uuencode binaryfile1.bin binaryfile1.bin
echo "\n end of email, blabla...."
}| mailx -m -s "mymail" username@domain.com

HTH,
Peter Geluk
Geoff Wild
Honored Contributor

Re: Using mailx to sned file as attachment

You can also use mpack:

Mpack and munpack are utilities for encoding
and decoding (respectively) binary files in
MIME (Multipurpose Internet Mail Extensions)
format mail messages.

http://hpux.ee.ualberta.ca/hppd/hpux/Users/mpack-1.5/

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Rita C Workman
Honored Contributor

Re: Using mailx to sned file as attachment

Couple points here to consider:
mailx is a messaging/broadcasting utility. Not a true emailing utility like elm or sendmail. With that said....

There a few ways to do this...

uuencode is one, but if your using this for clients you could run into issues of decoding it.

Then there is a third party software you could use like mpack. Can't comment on this, but folks on the Forums have used it.

My personal favorite is to use the include statement. It's quick & easy and great for scripting with..In other words you have a file, can be any kind, even an Excel spreadsheet on your UNIX box. You simply create dummy include file (I'll call it include.file) with the following information to point to the file to be attached:

[include application/msexcel base64]

or maybe for a simple text file:
[include text/plain base64]

and from your command line:
elm -s "This is a test" yourname@company.com < include.file

To see more examples of this subject just do a search and browse and enjoy...

Rgrds,
Rita