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!

add attachment to mail 3

Status
Not open for further replies.

hcclnoodles

IS-IT--Management
Jun 3, 2004
123
GB
hi there

I am currently using the following line to send mails out

mailx -s "subject here" you@yourcompany.com < file.txt

this places the text from file.txt i direct into mailx into the body of the mail, does anybody know how i "attach" this rather than print it in the mail


any help would be greatly appreciated
 
Have you searched the FAQ's - I suspect not. Try looking under the General Unix Discussion FAQs

Columb Healy
Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
 
uuencode unixfile file.doc | mailx -s "subject" username@domain.com

 
i am running solaris and when i run that command i get

#uuencode unixfile yscript.sh | mailx -s "hello" me@me.com

uuencode: ISO8859-15 to 646 conversion: Invalid argument
unixfile: No such file or directory
 
ok i tried the following

#uuencode yscript.sh | mailx -s "hello" me@me.com
uuencode: ISO8859-15 to 646 conversion: Invalid argument

in galgers example he used "unixfile" and "file.doc" was he trying to demonstrate sending 2 attachments ???
 
man uuencode

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Do this:

uuencode attachmentname attachmentname | mailx -v -s "subject here" address

Yes. You have to type the attachment name twice. If you have a text document in unix that you want to send to a Windblows box and don't want to convert it first, you can change the name of the attachment.

If the unix file is text.txt you can do this:

uuencode text.txt text.doc | mailx -v -s "Hi windblows" address,address,address

and the text.txt file will be sent with .doc suffix.

-Joe

BTW the manpage for uuencode is one the worst!
 
uuencode unixfile yscript.sh | mailx -s "hello" me@me.com


unixfile is your unix file or "data file".
yscript.sh is the filename that will be your attachment it will create it for you..
yscript.sh will be created for you.

Usually if I have data on unix and want to create a report for excel report, or doc. I will make the attchment:
yscript.doc
or
ysscript.xls

 
For some reason the command:

uuencode filename filename | mailx -s "Subject" youremail@here.com

is not working anymore for me, the body of the message has the uuencoded info but not the attachment.

Has anyone seen this?
 
Install mpack, much easier to use.

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Aix

thanks for your suggestion but I still have a few questions:

Can I install mpack without any admin/root privileges? I am just a regular user.
If I can't, any idea why the command above used to work and now doesnt?
 
What exactly are you typing {commmand line} and also, what kind of file are you trying to send. I remember way back in time I had the same problem..



 
The exact command is:

uuencode zeei.log zeei.log | mailx -s "MML ZEEI" myemail@whatver.com

zeei.log is a ASCII file with logs from a Wireless Switch.

I get the email, but I used to get the file zeei.log as an attachment, now it is in the body of the message in a different format (not ASCII), which is not legible.
 
Try it with changing the name of the second file..
Like:
uuencode zeei.log zeei$$.log | mailx -s "MML ZEEI" myemail@whatver.com
also try
uuencode zeei.log zeei.xls| mailx -s "MML ZEEI" myemail@whatver.com

or
Try just creating a simple "txt file". and send that..

Let me know if that works.


 
Hey Fserver

I am working with Nokia Switches too...

The syntax:

uuencode zeei.log zeei.log | mailx -s "MML ZEEI" myemail@whatver.com

It's correct.

Do it, save the attachment in your pc, open it using wordpad. (Right click on it-> Open with Wordpad) You'll see it in the right format.

Cheers.


 
Galger, I tried both and it didnt work.

Dmazzini,

this is what I get in my outlook email when I sent the command:

begin 644 zeei.log
M6EI%3TP[(`H@"B`*3$]!1$E.1R!04D]'4D%-(%9%4E-)3TX@."XQ+3`@"B`*
M0E13($%,05)-($Q)4U1)3D<@"B`*("`@("`@("`@("!.64--0E-#,#,@("`@
.
.
M("`@("`@(#`P(#`P(#`S($$Q(#`P(#`P("`*(`H@"B`*14Y$($]&($)44R!!
M3$%232!,25-424Y'(`H@"D-/34U!3D0@15A%0U54140@"@H@"D)!4T4@5%)!
M3E-#14E615(@4U1!5$E/3B!!3$%235,@2$%.1$Q)3D<@0T]-34%.1"`\14]?
(/B`*/"`@(`H@
`
end

I do not get an attachment, but instead I get this on the body of the message.. any ideas??
 
Outlook doesn't know how to handle the attachement because it isn't an attachment at all, all you've done is encode the file and mail it. Outlook understands MIME (RFC 3141) attachments and base64 has supplanted the venerable uuencode as the standard for 7 bit encoding 8 bit data for email.

In the link to biabam they mention Mutt. Since Micheal Elkins, the developer of Mutt, also wrote RFC 3141, I think you may have some success with it. If you have python installed on your machine, then you also have all the tools you need to send MIME compliant email attachement. If you want I can post the code to do it, it's about 6 lines... 3 if you don't care about readability.

Interestingly, on a MacOS X forum I found this link ( to a /bin/sh script that will create MIME compliant emails from the command line. It is well written and exceptionally well commented. It requires perl to Base64 encode the files and sendmail to transport them.

However, since you are sending text files, there is no reason to encode them at all, so even without perl, the above script would work for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top