Using MTA Management Commands on Linux
Let’s first look at reading messages stored in your local MTA. When
you log in to a shell session, you will receive a notification if
there are mail messages waiting for you. You can read messages for
local users from the local MTA directly from the command line using
the mail command at the shell prompt. When you do, a list of messages
is displayed. An example is shown in Figure 16-15.
Some services running on Linux are configured to send notification
messages to the root user.
These messages are stored in your user’s mail queue, which is located
in the
/var/spool/mail/
directory. The mail utility reads yourmessages directly out of your user’s queue file.
Because you’rerunning the mail utility on the same system where your queue resides,
you don’t need POP3 or IMAP support configured. You can enter the mailcommands shown in
Table 16-4 at the ? prompt.
An example of viewing a received message with the t command is shown
in Figure 16-16.
To send a message, you can also enter
mail recipient_address
at the shell prompt. You can then enter a subject line and the text of
your message. Press
ctrl-d
when you’re done to actually send the message. When you do, the message is delivered to the other user’s mail queue by your local MTA.
To view a list of unread messages in your mail queue, you can enter
mailq
at the shell prompt.
In addition to mail, many other packages are available that you can
install to read mail from the shell prompt. The key thing to remember
is that the user must run the mail command from the local shell
prompt. If the user isn’t using the local computer system, they must
ssh into the system to read mail.
You can also configure aliases for the MTA running on your Linux
system. Mail aliases redi- rect mail addressed to one user to another
user’s account. You use the
/etc/aliases
file to configure aliases.
This file defines one alias per line. The alias you define must point
to an existing e-mail address. The syntax for this file follows:
alias: list of real e-mail addresses (separated by commas)
For example, the following two aliases must be present in this file on
most Linux distributions:
postmaster: root
mailer-daemon: postmaster
These aliases cause any e-mail messages sent to the postmaster to be
automatically redirected to the root user. Likewise, any e-mail
messages sent to mailer-daemon will be redirected to post- master
(which will then be redirected to root). Depending on your
distribution, you will probably find that many aliases are defined for
you by default.
Here is an example:
# General redirections for pseudo accounts in /etc/passwd.
administrator: root
daemon: root
lp: root
news: root
uucp: root
games: root
man: root
at: root
postgres: root
mdom: root
amanda: root
ftp: root
wwwrun: root
squid: root
msql: root
gnats: root
nobody: root
# "bin" used to be in /etc/passwd
bin: root
Of course, you can enter your own custom aliases if needed. Just open
the aliases file in a text editor and add the appropriate aliases, one
per line. When done configuring aliases, you must run the
newaliases
command at the shell prompt as root to enable them.
You can also use the
~/.forward
file in your user’s home directory to configure forwarding. Most Linux MTAs
check for the existence of this file in the user’s home directory to configure
forwarding of messages.
You can open/create the file in a text editor and enter the e-mail
address to which you want to forward e-mail. If you are forwarding to
a local user, just enter the username. If you’re forwarding to a
remote user account, enter username@domain.com. If you need to forward
messages to multiple recipients, separate them with a comma.
The MTA will treat the addresses you enter in this file as an alias.
This causes all e-mail to be forwarded to the forwarding e-mail
address. Messages will not be delivered to the original user’s
mailbox.
LX0-104 Exam Objectives (P)
No comments:
Post a Comment