Using mailx to sned file as attachment (16 Views)
Reply
Advisor
KAMARULZAMAN HJ ALI
Posts: 47
Registered: ‎08-17-2000
Message 1 of 8 (16 Views)

Using mailx to sned file as attachment

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

Rgds.
Exalted Contributor
Steven E. Protter
Posts: 33,806
Registered: ‎08-15-2002
Message 2 of 8 (16 Views)

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
Honored Contributor
Michael Tully
Posts: 7,905
Registered: ‎04-15-1999
Message 3 of 8 (16 Views)

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 ?
Honored Contributor
Hoefnix
Posts: 529
Registered: ‎10-16-2003
Message 4 of 8 (16 Views)

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
Honored Contributor
Karthik S S
Posts: 1,511
Registered: ‎07-17-2002
Message 5 of 8 (16 Views)

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
Honored Contributor
Hoefnix
Posts: 529
Registered: ‎10-16-2003
Message 6 of 8 (16 Views)

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
Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 7 of 8 (16 Views)

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.
Honored Contributor
Rita C Workman
Posts: 3,791
Registered: ‎08-03-2000
Message 8 of 8 (16 Views)

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


The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.