MH Aliases
[previous]
[next]
[table of contents] [index]
When you address a message, aliases can
shorten the address and make it easier to remember.
Here's an example.
You're working on a project with three other people, and you stay in touch
by email.
If you didn't use mail aliases, you might address a message to all of them
like this:
To: alissa@ketneg.com, uunet!abo!pxu341i, abd@mvus.bitnet
What a pain to type those addresses each time you want to send mail!
Instead, pick a name (an alias) for that group of addresses.
Store that alias name and the addresses in an
alias file, then tell the MH commands where your alias file is.
After that, when you send mail, all you have to type is the alias name -- for
example:
To: project
The next three sections explain the syntax of an MH alias file, how to make
MH commands use it, and how to list MH aliases.
After that is a section about another kind of aliases, those handled by your
system MTA.
Let's go on with the example.
You'd put this entry into your alias file:
project: alissa@ketneg.com, uunet!abo!pxu341i, abd@mvus.bitnet
Your aliases file (or whatever you name it -- see the
Section Naming MH Alias Files)
can have as many entries as you need.
Put one alias on each line.
If an alias has lots of addresses in it, you can continue it on other lines by
ending each line with a backslash (\), like this:
project: alissa@ketneg.com, uunet!abo!pxu341i, \
abd@mvus.bitnet, moe%stooge@guys.org, \
lizv@geknichon.xyz.edu
You don't need to indent the continuation lines, but I think it makes
the meaning clearer.
Long alias files can be hard to maintain.
("Who is k38d4@kumquat.usnd.edu, anyway, and why is that person in
my alias file?")
Adding comment lines and names can identify aliases and the addresses on them.
The Example below shows how.
A line that starts with a semicolon (;) is a comment.
Legal RFC 822 syntax works for addresses in most cases, so you can
include names.
As above, indent continuation lines and end all but the last line of the
alias with a backslash (\).
Example: An MH alias file with comments and real names
;
; BOOK REVIEWERS:
;
rvwrs: Freida Kumzickle <kumzy@hoople.usnd.edu>,\
Ethel Michaelman <ethel@edsel.org>,\
"Dr. Mary Tallman" <tallman@lab.army.mil>,\
Harry Wielstrom <weilstrm@world.tsd.com>
Aliases can include other aliases.
The other aliases must be listed later in the alias file.
For example, the allgroups alias in this alias file would send to all
the groups listed below it:
allgroups: mkt, sls, mgt
mkt: randy, xandra
sls: paula, nathan, will
mgt: gilligan, ozzie, harriet
But in the following alias file, the allgroups alias would not work
because mkt, sls, and mgt are listed before it:
mkt: randy, xandra
sls: paula, nathan, will
mgt: gilligan, ozzie, harriet
allgroups: mkt, sls, mgt ...this won't work
So, always list an alias before the other aliases it references.
Some mail transfer agents, such as sendmail, also have their own
alias files (sendmail uses a file like /usr/lib/aliases or
/etc/aliases).
The Section Aliases in Your Transfer Agent
introduces MTA aliases.
You can also use your personal or group alias files to send mail to users
who are members of UNIX groups.
(Primary group members are usually listed in the system
/etc/passwd file.
Secondary group members are listed in /etc/group.)
For example, let's say that joeb, amyl, and edwina
are primary members of the UNIX group named staff.
If you put entries like these in your alias file:
gurus: +staff
everyone: *
and you addressed a message to gurus, it would be sent to everyone who
is listed in the system /etc/passwd file as being a member of the
UNIX staff group... that's joeb, amyl, and edwina.
If you sent mail to the alias everyone, it would go to every user who
has an account on your computer.
These special alias entries depend on your operating system,
local computer, and more... there are too many possibilities to explain
thoroughly here.
If you have questions and you understand UNIX pretty well, start with the
mh-alias(5)
manual page on your system -- it's terse, but it has examples.
Otherwise, show this book to an expert on your computer for help -- or grab a
manual that explains the user and group setup on your version of UNIX.
You can take a list of addresses from a file by using a left
angle bracket (<) and a filename.
Here's an example of a file named /usr/ourgroup/staff and how you
could use its addresses in an alias named mygroup:
% cat /usr/ourgroup/staff
berthab
sherryo
vickiz
bigboss@gold-plated.bigcorp.com
% cat aliases
mygroup: < /usr/ourgroup/staff
Always be sure to use an absolute pathname, starting with a slash (/),
no matter where the address file is stored.
If you don't always use MH for sending mail (for instance, you might work
on a set of machines, not all of which have MH) you can keep your aliases
in the .mailrc format used by many other MUAs.
Here's a sed command that creates an MH alias file from .mailrc.
You could put this in a shell function or alias -- or a little shell script.
The square brackets in the fourth -e expression contain single tab
and space characters:
sed -e '/^set/d' -e '/^unset/d' -e '/^ignore/d' \
-e 's/alias [^ ]*/&:/' -e 's/^alias //' \
-e 's/#/;/' $HOME/.mailrc > /yourMHdir/aliases
Another Section shows a way to send a message
with only some of the addresses in an alias.
Also see the ali command, which is good
for testing your alias file.
The whom
command is another good way to test aliases.
You decide to name your alias file aliases
and store it in your MH directory.
To store those three addresses in an alias called project, you'd
change to your MH directory (which is usually named Mail), then use
an editor like vi to make the file:
% cd Mail
% vi aliases
Tell MH commands where your alias file is:
You can share alias files -- say, between members of your group
or students in a class.
For this to work, the alias file has to be readable by everyone (one
way to find out is to try to read the alias file from your
account with
cat(1)).
You can put the alias file anywhere on the filesystem -- it doesn't have to be
in an MH mail directory.
Just add a -alias entry to your MH profile -- for example,
in MH Version 6.6 and before:
ali: -alias aliases -alias /usr/groupproj/mh_aliases
send: -alias aliases -alias /usr/groupproj/mh_aliases
whom: -alias aliases -alias /usr/groupproj/mh_aliases
If there's an alias with the same name in more than one file, MH will use
the first alias it finds -- and it reads alias filenames left to right.
MH 6.8 and above accept multiple filenames in the MH profile
Aliasfile: entry.
In MH 6.7 through 6.7.2, you can only put one alias filename in the
Aliasfile: entry.
Other aliases have to be listed on the individual command entries.
So in MH 6.7-6.7.2, the example above could look like:
Aliasfile: aliases
ali: -alias /usr/groupproj/mh_aliases
send: -alias /usr/groupproj/mh_aliases
whom: -alias /usr/groupproj/mh_aliases
Note that there may be a system-wide alias file in the MH library directory
named MailAliases.
Where it is and what aliases it has depend on your system postmaster or
system administrator.
If MH is trying to find an alias, and if the alias isn't in any of
your -alias files, it will search the system-wide file (if that
file exists).
If your alias file is in a directory that's shared between more than one
computer, through a networked filesystem (such as NFS), be careful
about the files it refers to.
For instance, in the examples above, let's say that you create your alias
file on the host hosta where the directory /usr/groupproj exists.
Your home directory and alias file are shared by hostb and hostc,
but the /usr/groupproj directory is only available on hosta.
So, the aliases in /usr/groupproj/mh_aliases may cause mail bounces
if you send to them from hostb or hostc.
There are plenty of workarounds -- including a different MH profile, with its
own alias file entries, on each host (see the Section
Multiple MH Sessions for tips on that).
If you have set up MH aliases,
you can see who belongs to an alias with the ali command.
For example, to see who's in the gurus alias:
% ali gurus
danro, rada, rbwilbur, ahof
If you don't give it an alias name to list, ali will list all the
MH aliases you can use.
The -user switch makes ali work in the opposite way:
you give
ali the address and it finds the aliases which contain that address.
The -list switch gives output in a column.
It's used in shell programming and with commands like
mhmail.
Here's the previous example using -list:
% ali -list gurus
danro
rada
rbwilbur
ahof
After it searches your alias file(s),
the ali command automatically searches the system MH alias file if
there is one.
If you don't want it to do this, use the -noalias switch.
You can type that on the command line or add it to your MH profile.
Your system MTA (transfer agent) probably has its own alias file.
For instance, sendmail's file has a name like /usr/lib/aliases
or /etc/aliases.
Your transfer agent's aliasing probably works about the same as MH alias
files, though its syntax might be different.
Also, the ali command won't show aliases in a system alias file
(but whom -check might,
depending on your transfer agent).
If everyone on your system uses MH, you can put system-wide aliases in the MH
alias file.
But if some people run other user agents, system-wide aliases should
go in the transfer agent's alias file.
Also, if you have an alias with many members, you might want to put it in the
system alias file.
That's because MH replaces the alias name with the expanded list of
addresses, which can lead to some very large mail headers.
Finally, aliases that are set by the transfer agent are probably
"visible" to users on other computers.
For example, if the site foo.xxx.com put an alias
called staff in its sendmail aliases file, then anyone
in the world could mail to staff@foo.xxx.com and have it delivered
to the addresses in that alias.
MH aliases can't be used that way.
|