Contact us |
on a system or on different systems. Mail servers facilitate the routing of messages amongst various systems and users. A mail transport agent (MTA) program almost always comes as a standard part of most Linux/Unix systems. The most popular MTA on Linux and Unix systems is the ubiquitous “sendmail” program. Sendmail is a back-end program that moves emails over networks (e.g the internet) Users on a system use a front-end application called a “mailer” or a “mail client” to interact with the mail system. Most systems store users’ mail in the “/var/spool/mail/<username>” file. The e-mail client (mailer) then parses the file and displays it in a logical format. We will be looking at a mailer that can be used from the command line as well as a mailer that can be used in a GUI environment. mail: Usage: mail -iInv -s subject -c cc-addr -b bcc-addr to-addr ... - sendmail-options ... mail -iInNv -f name mail -iInNv -u user The interactive commands for “mail” are: t <message list> type messages n goto and type next message e <message list> edit messages f <message list> give head lines of messages d <message list> delete messages s <message list> file append messages to file u <message list> undelete messages R <message list> reply to message senders r <message list> reply to message senders and all recipients pre <message list> make messages go back to /usr/spool/mail m <user list> mail to specific users q quit, saving unresolved messages in mbox x quit, do not remove system mailbox h print out active message headers shell escapecd directory chdir to directory or home if none givenA <message list> consists of integers, ranges of same, or user names separated by spaces. If omitted, Mail uses the last message typed. A <user list> consists of user names or aliases separated by spaces. Aliases are defined in .mailrc in your home directory To check for the sendmail program 1. While logged in as the root user, make sure you have sendmail installed. Type: root@serverXY root# rpm -q sendmail sendmail-* If you don’t have the program installed, download the package or source files from a download site or from the installation media and install it To check the status and to control sendmail 1. Check if the mail server is running, type: root@serverXY root# service sendmail status 2. Restart the mail server. Type: root@serverXY root# service sendmail restart Shutting down sendmail: OK Starting sendmail: OK 3. What is the command to stop the mail server? 4. For which runlevels is the mail server currently configured to start up automatically? To view your mails 1. Type: root@serverXY root# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 4 messages 4 unread U 1 Wed Oct 16 20:00 63/560 "Re: Postmaster " U 2 MAILER-DAEMON@server Wed Oct 16 20:00 109/1940 "Returned mail: " U 3 Wed Oct 16 20:01 14/435 "Re: LogWatch fo" U 4 Thu Oct 17 04:02 68/2437 "LogWatch for lo" & From the output above the root user has 4 new unread (U) messages. 2. The mail prompt above is interactive. To read the first mail type the number <1> at the ampersand ( &) prompt. Message 1: From root Wed Oct 16 20:00:30 2002 Date: Wed, 16 Oct 2002 20:00:29 -0400 From: root <root@server04.example.org> To: , Subject: Re: Postmaster notify: see transcript for details Cc: ……………………… 3. When you are done reading a mail, press the letter <h> to return to the main mail menu. At the ampersand mail prompt type the letter <q> to quit the mail program. Message 1: From root Wed Oct 16 20:00:30 2002 Date: Wed, 16 Oct 2002 20:00:29 -0400 From: root <root@server04.example.org> To: , & q To send mail interactively You are going to send an e-mail to the “unreasonable” user and also send a copy (carbon copy CC) to yourself – i.e. root. 1. Make sure you are at the ampersand prompt. Type “mail” or the letter “m” Mail version 8.1 6/6/93. Type ? for help. "/root/mbox": 4 messages > 1 root@server04 Mon Oct 14 04:02 29/691 "LogWatch " 2 Tue Oct 15 04:02 103/3294 "LogWatch " 3 Wed Oct 16 13:11 63/1922 "LogWatch " 4 Wed Oct 16 20:00 63/561 "Re: Postmaster " & mail unreasonable@<FQDN> At the Subject Prompt Type in the subject: Subject: Mail for unreasonable user After typing the subject, press <ENTER> and type the body of the mail as below This is a nasty e-mail for all the the dumb things you do on the system and for all the trouble you put me through. After completing the mail . Press <ENTER> and Type a single dot (“. “) on a single line all by itself. This tells the mail program that you are done composing the mail. Type: . When prompted with the CC: field type: Cc: root@<FQDN> Press <ENTER> when done and type the letter <q> at the mail prompt (& sign). & q To run commands from the mail prompt Knowing fully well that you don’t remember what <FQDN> stands for, launch the mail program again and type an exclamation mark followed by the command you want to run. e.g. Type: & ! domainname –f To read another user’s mail This isn’t a very nice thing to do, but you may have a genuine/legitimate need to access another user’s mail box as the superuser. All you are doing is running the mail command as another user. 1. While logged in as the superuser, type the command below to view the mail headers for the unreasonable user. Type: root@serverXY root# mail –u unreasonable One of the mails you see, should be the one you sent earlier to that user, with the subject “Mail for unreasonable user”. You have had a change of heart and decided you don’t actually want that user to read that mail (assuming it hasn’t been read already). What is the command to delete that mail?
|
Login... |
||||