Operating System - HP-UX
1825768 Members
2049 Online
109687 Solutions
New Discussion

Not able to attach any file using mailx

 
praveen..
Super Advisor

Not able to attach any file using mailx

Hi,
I want to send the output of a script to my email id ,
I am not able to attch that file.

# cat test.log | mailx -s "log file" praveen@company.com

I am getting the output on my email id as a message not an attachment.

while i want to get test.log file as an attachment.

I tried with uuencode.

# uuencode test.log | mailx -s "attached log file" praveen2company.com

this is a continous process and i need to kill it using

(Interrupt -- one more to kill letter)
Null message body; hope that's ok
root@grouse:[/opt/cpu_mem/cpumem_logs]
#


Please suggest

how to attach a file
13 REPLIES 13
Peter Godron
Honored Contributor

Re: Not able to attach any file using mailx

Praveen,
please try:
uuencode test.log test.log | mailx -s "attached log file" praveen2company.com

See "man uuencode"
Steven E. Protter
Exalted Contributor

Re: Not able to attach any file using mailx

Shalom,

if you are willing t use another took here is a proven production program:

http://www.hpux.ws/mailfile2

Note that smtp gateway software that is not properly patched will destroy attachments sent even by this fine program.

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
vinod_25
Valued Contributor

Re: Not able to attach any file using mailx

Hi Praveen,

Pete has the right syntax ... use it

uuencode test.log test.log | mailx -s "attached log file" praveen@company.com

I have just edited the email address part for clarity.

Provide points to PETE for his solution text.

Regards,
Vinod
praveen..
Super Advisor

Re: Not able to attach any file using mailx

Hi,
I tried with
#uuencode test.log test.log | mailx -s "attached log file" praveen@company.com

Now i got the hash # prompt again, it looks that commands has sucessfullu completed.

But I am not getting any mail.
while I am getting mail using....but not an attachment..
# cat test.log | mailx -s "log file" praveen@company.com

Please suggest
Yang Qin_1
Honored Contributor

Re: Not able to attach any file using mailx

Hi, check /var/adm/syslog/mail.log and see what was happened with the mail with attachment (uuencode ...).

If you just want to attach a log file for one time and you don't mind to attach it interactively, you can use elm instead of mailx.

You can also attach a file which sendmail command by writing a mail header

Yang
Dave La Mar
Honored Contributor

Re: Not able to attach any file using mailx

Try any of the examples on the attached that meet your needs.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
Rajeev  Shukla
Honored Contributor

Re: Not able to attach any file using mailx

I use mpack/munpack to do this.
You can download it from http://hpux.connect.org.uk and it works too good to send files as an attachment.
Arturo Galbiati
Esteemed Contributor

Re: Not able to attach any file using mailx

Hi Preveen,
what's happend is that Microsoft chnage the echange server and now to be able to see your file as attachment you can use:
1. add the -m flag to your mailx
2. create a file .mailrc in your $HOME directory:
cat<>$HOME/.mailrc
set mimeheader=no
EOF

The second solution is better because you will avaoid to chnage all your script adding -m flag.

HTH,
Art
praveen..
Super Advisor

Re: Not able to attach any file using mailx

Hi,
I tried with this command:
# ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com

This command is working but only for *.txt files, not for any *.csv and *.xls files.

Please suggest.

I have also installed mpack utility,
can anybody please let me know how to use it?
I countnot get more information from man pages of mpack.

please suggest

Igor Sovin
Super Advisor

Re: Not able to attach any file using mailx

Hi praveen!

Try sendmail instead of mailx

uuencode test.log test.log | sendmail praveen@company.com
Dave La Mar
Honored Contributor

Re: Not able to attach any file using mailx

Try this, which we use for html files -

uuencode local_file local_file.html" | mailx -s "Subject" someone@somewhere.com


Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: Not able to attach any file using mailx

Sorry, one extra double quote shouldn't have been there.
Should have read -
uuencode local_file local_file.html | mailx -s "Subject" someone@somewhere.com

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
praveen..
Super Advisor

Re: Not able to attach any file using mailx

I am able to send an attachment using this command:

# ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com


but now I am not able to send the message body,

I am opening a new thread...."Not able to mail message body & attachment together"

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1075053

Thanks for your help