Operating System - HP-UX
1830909 Members
1669 Online
110017 Solutions
New Discussion

Re: mailing a file using mailx

 
dave broome_1
Advisor

mailing a file using mailx

Hi,

HP/UX 10.20

Can Anyone give us a nice easy way of mailing out a file, or the contents of a file, from our HP server to root (this then is forwarded to a list of users)? Ideally we would like to write a simple script that we could schedule, maybe via cron??

Any suggestions please.

Dave
8 REPLIES 8
T G Manikandan
Honored Contributor

Re: mailing a file using mailx

echo "hello" | /usr/bin/mailx -s "test" dave@hp.com


Thanks
Rajeev  Shukla
Honored Contributor

Re: mailing a file using mailx

first i guess you have sendmail configured and running. Alias root in /etc/mail/aliases to the group of people you want to send mail to.
Then to mail a file say fileA.
do
cat fileA|mailx -s "subject" root@hostname

have this line in your scripts in cron and that will take care of it.

Rajeev
T G Manikandan
Honored Contributor

Re: mailing a file using mailx

John Meissner
Esteemed Contributor

Re: mailing a file using mailx

edit your /etc/sendmail.cf
which could also be located in /etc/mail/sendmail.cf

uncomment the "DS" option and make sure that you also have the fully qualified domain name of your smtp server after it. i.e.:
DS mailserver.mydomain.com

then

cat file | mailx -s "subject" -r return_address address_to_send_to
or

mailx -s "subj" -r return_address address_to_send_to < file
All paths lead to destiny
Jose Mosquera
Honored Contributor

Re: mailing a file using mailx

Hi,
What about of sendmail command? The sendmail command is more customizable, Just try this:

1) When message is inside of body mesage:

Set a variable that contain the body text, i.e:
BODY=`cat file_of_body_text`
echo "Importance: High\nSubject: Test mail\n\n$BODY"|sendmail user_box@domain

This result in an email with High Priority Flag, Subject: "Test mail" and a body text.

2) When message is an attached file:

(echo "Importance: High\nSubject: Test mail\n\n$BODY";uuencode attached_file attached_file)|sendmail user_box@domain

Note: attached_file must be twice!
This result in an email with High Priority Flag, Subject: "Test mail" with an attached file. Also you can use "C.C:" and "From:" fields.

Rgds.
Chris Vail
Honored Contributor

Re: mailing a file using mailx

#!/usr/bin/ksh
for ADDY in `cat /PATH/ADDYFILE`
do
uuencode /PATH/FILE /PATH/FILE|mailx -s "subject" $ADDY
done

This attaches the FILE as a MIME compliant attachment (for .csv's, .txt's and others) and sends it to every email address in ADDYFILE. Its quick, dirty and works like a charm. We do it every day here.



Chris
dave broome_1
Advisor

Re: mailing a file using mailx

Thanks for all of your help with this one. I have successfully sent the mail out and scheduled a simple script to do the job. Seems like the task for which the phrase "many ways to skin a cat" was written. Is that an English phrase?
Mike Fisher_3
Advisor

Re: mailing a file using mailx

Acc to "World Wide Words"

Charles Kingsley - Westward Ho! in 1855:
???there are more ways of killing a cat than choking it with cream???.

Mark Twain, "A Connecticut Yankee in King Arthur???s Court", 1889
???she was wise, subtle, and knew more than one way to skin a cat???

"Way down East; or, Portraitures of Yankee Life, Seba Smith of about 1854:
???This is a money digging world of ours; and, as it is said, ???there are more ways than one to skin a cat,??? so are there more ways than one of digging for money???

First recorded in John Ray???s collection of English proverbs as far back as 1678.
Some writers have pointed to its use in the southern states of the US in reference to catfish
The best things in life aren't things