Sponsored Content
Full Discussion: Problem with mailx in HP_UX
Top Forums Shell Programming and Scripting Problem with mailx in HP_UX Post 302884324 by vbe on Monday 20th of January 2014 04:32:08 AM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
MHMAIL(1)                                                            [nmh-1.5]                                                           MHMAIL(1)

NAME
mhmail - send or read mail SYNOPSIS
mhmail [addrs ...] [-body text] [-cc addrs ...] [-from addr] [-subject subject] [-version] [-help] DESCRIPTION
mhmail is intended as a replacement for the standard Berkeley mail program (mail or mailx), which is compatible with nmh. This program is intended for the use of programs such as cron, which expect to send mail automatically to various users. It is also used by various nmh commands to mail various error notifications. Although mhmail can be used interactively, it is recommended that comp and send be used instead to send messages. When invoked without arguments, it simply invokes inc to incorporate new messages from the user's maildrop. When one or more users is specified, a message is read from the standard input and spooled to a temporary file. mhmail then invokes post with the name of the tempo- rary file as its argument to deliver the message to the specified user. The -subject subject switch can be used to specify the "Subject:" field of the message. By default, mhmail will read the message to be sent from the standard input. You can specify the text of the message at the command line with the -body text switch. If the standard input has zero length, mhmail will not send the message. You can use the switch -body "" to force an empty message. Normally, addresses appearing as arguments are put in the "To:" field. If the -cc switch is used, all addresses following it are placed in the "cc:" field. By using -from addr, you can specify the "From:" header of the draft. Naturally, post will fill-in the "Sender:" header correctly. FILES
/usr/bin/mh/inc Program to incorporate maildrop into folder /usr/lib/mh/post Program to deliver a message /tmp/mhmail* Temporary copy of message SEE ALSO
inc(1), post(8) DEFAULTS
None CONTEXT
If inc is invoked, then inc's context changes occur. MH.6.8 11 June 2012 MHMAIL(1)
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy