Problem with mailx in HP_UX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with mailx in HP_UX
# 1  
Old 01-20-2014
Problem with mailx in HP_UX

Hello Guys ,

I have read various threads over this forum related to mailx command but could not find my answer , so starting this new thread.But if you still find a thread related/similar to this one ,please redirect me their and close this one.

My requirement is to send a email having below all:-
FROM
TO
CC

I am all most near to my requirement but having some minor problems in my below code :-

First :-
Code:
(cat <Filename>;uuencode ${FILE} ${FILE}) | mailx -s "${EMAIL_SUBJECT}" -r ${EMAIL_SENDER} ${EMAIL_RECEPIENT}

I get my email and can see FROM and TO .

Second :-
Code:
(cat <Filename>;echo '~c ${EMAIL_CC}';uuencode  ${FILE}  ${FILE} ) | mailx -s "Test" ${EMAIL_RECEPIENT}

I get my email with CC and TO. FROM here remains as machine name .

Thrid :-

But when i try all three together i.e FROM,TO,CC. I am not getting the person in CC in my email and it shows up in email content as "~c <email id>"

Code:
(cat <Filename>;echo '~c ${EMAIL_CC}';uuencode  ${FILE}  ${FILE} ) | mailx -s "Test" -r ${EMAIL_SENDER} ${EMAIL_RECEPIENT}

Could any one help me on this.

Cheers !!!!!!!!!!!!!!!

---------- Post updated at 02:55 AM ---------- Previous update was at 02:51 AM ----------

FYI... I have tried with all different address for email . But still didn't work.
# 2  
Old 01-20-2014
Found this in my old doc:
Quote:
Command-line mailing with subject, body text and attachments (HP-ITRC)
DocId: KBAN00000679 Updated: 20010420
DOCUMENT
PROBLEM:

Customer wants to be able to create a script to email a binary file to a
distribution list, with a subject line so recipients can readily identify it,
and body text explaining what the attachment is and what to do with it. To do
that, they need a method of creating and sending such a message.

RESOLUTION:

The method involves assembling a message from two separate parts, consisting
of a header which contains the body text and of a uuencoded attachment, then
sending it using the "-t" sendmail flag, which causes sendmail to scan the
message body for such things as addresses and the subject.

The first part of the message is a header, which looks like this:

To: <address or alias>
Cc: <address or alias>
Bcc: <address or alias>
Subject: <subject>
<blank line>
Then beginning on this line, you write the body text you want to include.
<another blank line, just to be safe>

As you can see, the customer could easily put together a template header file
with variables in key positions, so a script to create and send the messages
could just grab the template and substitute the necessary values for the
variables. It's not necessary to include bcc or cc lines if they're not going
to be used.

Creating the message, then, is a matter of appropriately modifying a copy of
the header, and writing it to a temporary file. Then uuencode the attachment
file and ">>" redirect it to the same temporary file. Now send the contents of
that temporary file to sendmail, using the "-t" flag.

For example, let's say you have a report that you always send to the same
people, always using the same body text and subject line. For that you could
create a fixed header file, called "header" in this example. To distribute the
report:

# cp header > /var/tmp/mailtemp
# uuencode /path/datafile datafile >> /var/tmp/mailtemp
# cat /var/tmp/mailtemp | sendmail -t
# rm /var/tmp/mailtemp

That's all. Because of the "-t" flag, sendmail will read the header for
addressing and subject information. Uuencoded files with a ".csv" suffix sent
in testing arrived at an Outlook client as attachments which called up Excel
just as they should, while the body text part of the header file arrived as
body text.

Aliases were mentioned above in the description of the header. This is part of
sendmail, and works whether you're sending mail using sendmail alone, or with
ELM or mail or mailx or any client using sendmail as a transport vehicle.
In /etc/mail there's a file called "aliases," and in it you can define both
individual aliases and mailing lists. The basic format can be seen by just
looking at the file or consulting the man page for aliases(5). To define a
list, you start the line with the alias for the list, then after a ":"
delimiter, list the addressees (full address or alias) separated by commas.
It's okay to add a space after the comma for clarity. All addresses have to be
on the same line as the alias for the list; a new line is taken as the end of
the list. Sendmail doesn't usually use the aliases file itself, though, but
rather "aliases.db," so after you're done editing the aliases file you have to
issue the command "newaliases" to re-read the aliases file and re-write the
aliases.db file.
# 3  
Old 01-20-2014
Hello vbe,

Thanks for ur reply . But my problem still not addressed properly .

I still need FROM been added to my mail .

Will adding FROM to header file works ?I tried but no luck .


Thanks,
Himanshu Sood
-------------------------------------------
All,

Also i see only a single reply to my post , is this because there is no option available in HP or some other reason ?
Guys please provide ur valuable suggestions .
Regards
# 4  
Old 01-21-2014
Let me know if you want me to move your post to HP-UX specific...
# 5  
Old 01-21-2014
Why don't you use sendmail instead?
Code:
/usr/sbin/sendmail

There are several examples in this forum regarding sendmail usage.
# 6  
Old 01-21-2014
As was suggested early, assemble the mail header yourself. Use the more primitive mail or sendmail rather than mailx.
In one line:
Code:
(echo "To: $EMAIL_RECEPIENT"; echo "Cc: $EMAIL_CC"; echo "From: $EMAIL_SENDER; echo "Subject: $EMAIL_SUBJECT"; echo ""; cat <Filename>;uuencode $FILE $FILE) | mail "$EMAIL_RECEPIENT"

The EMAIL_RECEPIENT (correct spelling RECIPIENT) is mentioned twice; mail's command line argument goes to the envelope (represented as inititial "To " line in an SMTP mail, before the header follows with the "To: " line.)
As a reader-friendly multi-line script:
Code:
{
echo "\
To: $EMAIL_RECEPIENT
Cc: $EMAIL_CC
From: $EMAIL_SENDER
Subject: $EMAIL_SUBJECT
"
cat <Filename>
uuencode "$FILE" "$FILE"
} | mail "$EMAIL_RECEPIENT"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

HP_UX to Linux migration

I need set of commands, names and location that differ between HPUX and Linux. I have the same for Solaris to Linux migration guide in Red book from IBM. I need for HPUX and Linux on the same lines. (1 Reply)
Discussion started by: mohtashims
1 Replies

2. HP-UX

how to find the character encoding of a file in hp_ux

how to find the character encoding of a file in hp_ux (1 Reply)
Discussion started by: alokjyotibal
1 Replies

3. UNIX for Advanced & Expert Users

mailx problem

I executed my script in linux environment so Here Im facing problem.In linux has mailx command but if i include in following way Im getting error like ./script2.sh: line 6: mailx: command not found. if I use mail command also Im getting same error. $ cat script2.sh while ps | ./pwtst do... (5 Replies)
Discussion started by: ksrivani
5 Replies

4. HP-UX

Sorting top command output in HP_UX 11.11

Hello all, I've been woking on Solaris and Linux (Red Hat) so far but now I've inherited an HP-UX system and having minor issues with syntax...Appreciate if you could help me out here.. 1) I'm trying to sort the output of the top command in HP-UX 11.11 by pressing O (capital O) after typing... (2 Replies)
Discussion started by: luft
2 Replies

5. HP-UX

HP_UX installation disks - is this what i need?

Hello Folks, I recently screwed up and accidently deleted a lot of very necessary system files on my HP-UX test machine at home during a 'cleanup' of disk space. I think I have no option other than to reinstall the OS now. Its not something I'd planned to do or that I've done before but... (3 Replies)
Discussion started by: Jim66
3 Replies

6. UNIX for Dummies Questions & Answers

mailx -c PROBLEM

hi All, i want to email to abc@abc.com which will be in "to" and to def@def.com which will be in "cc". i tried like this: mailx -s "Total Collection" abc@abc.com -c def@def.com but i took error :( How can i success? Thanx so much. ---------- Post updated at 08:19 AM... (1 Reply)
Discussion started by: temhem
1 Replies

7. HP-UX

How to create a partition in HP_UX?

I'm using 11i v3. I have a san disk; how to creeate a partition in a normal way similar to fdisk in linux? (not using lvm) The other question is: I created a partiton using lvm and mounted it. experiment is to take a block level snapshot and attach it as a different disk. I attached the disk... (3 Replies)
Discussion started by: ilan
3 Replies

8. UNIX for Advanced & Expert Users

problem with mailx

Hi unix lovers, I have some problem with using mailx. I want to send mail as per the instructions in a file. The mail does not reach to CC recepients. To get a clearer picture, this is what I am typing on unix prompt. $ $ mailx ashishp@suntech.com < mail.txt $ And my mail.txt looks... (7 Replies)
Discussion started by: shriashishpatil
7 Replies

9. UNIX for Dummies Questions & Answers

mailx problem

Is there a size limit on the file that can be sent using mailx? I'm trying mailx -s "alertlog" tome@work < /dir/my.log and I only get a portion of the log. The newest portion of the log is not included in the mail. Additionally, I would like the option of mailing just the last 100... (1 Reply)
Discussion started by: djbartkow
1 Replies

10. UNIX for Dummies Questions & Answers

mailx problem

Here is a question I have, maybe someone can help me out. I am new to this UNIX thing. :) I have a file called elist. In this file is a list of 25 email adresses. How can I write a simple command line for that will read the names of the file and send it to each of the email addys. Can I... (2 Replies)
Discussion started by: iastorms
2 Replies
Login or Register to Ask a Question