<<

Sendmail Lab – Part 1 The sendmail program was originally written by while he was a student and staff member at the University of California at Berkeley. The sendmail program plays a variety of roles: • Listens to the network for incoming mail, • Transports mail messages to other machines • Hands local mail over to a local program for delivery • Appends mail to files, Pipes mail through other programs, • Queues mail for later delivery • Understands the aliasing of one recipient name to another

Objectives: (1) Study the default SENDMAIL configuration file supplied with your distribution. (2) Use SENDMAIL to send electronic messages to local users, and files. (3) Explore and manage SENDMAIL's mail queue. Prerequisite: Complete STMP Lab. You should do this lab on the same machine as you did your SMTP lab. Reference: Distribution Documents CentOS 5.x /usr/share/sendmail-cf/README

IMPORTANT: Some of the commands in this lab must be execute as “root”. Please login as a regular user and “su -” to root when necessary.

1. Version Information: Program/Package Name Version GNU/Linux Distribution CentOS 5.x / RHEL 5.x sendmail rpm sendmail-cf rpm sendmail-doc rpm sendmail-devel rpm

2. The name of the sendmail configuration file is called “sendmail.cf”. Use the “rpm -ql” command to determine which of the above four packages contains the file and find out its path. (hint: rpm -ql [package name] | grep sendmail.cf)

Path: ______Package: ______

OPS535 Lab – Sendmail Part 1 November 2009 Page 1 of 6 3. Change to sendmail.cf's directory, execute the following command and record the output: grep AliasFile sendmail.cf

Output:______

4. The output from step 3 indicates which file will be used as the mail aliases file. According to RFC822, all user names are case-sensitive except the name “postmaster”. But sendmail, when processing its aliases file, views all names as case-insensitive. Substitute the word “AliasFile” by the actual file name of the aliases file and execute the following command. Record the output.

grep ops535 AliasFile

Alias Name Aliase List ops535 postmaster smtp-lab

Execute the following commands and answer questions (a) and (b):

/usr/sbin/sendmail -v -bv postmaster

/usr/sbin/sendmail -v -bv smtp-lab

(a) If a message is addressed to “postmaster”, who will actually receive the message?

______(b) If a message is addressed to “smtp-lab”, who will actually receive the message?

______

5. Study the sendmail aliases file in your system. If you want all the messages addressed to “postman” in you machine to go into your mail box ( you will get those mails when you login to the system using your own login account), add the following line to the alias file:

postman: your_user_name

Sendmail does not read the aliases file directly, instead, it reads the dbm version of the aliases file called “aliases.db”. Execute the command “newaliases” to update the aliases database file. Run the “newaliases” command and record the output.

______

6. To verify that the alias for “postman” works as expected, create a file called “mail.txt” and execute the following command:

/usr/sbin/sendmail -v postman < mail.txt

OPS535 Lab – Sendmail Part 1 November 2009 Page 2 of 6 Can you access the mail message for “postman” under your user account?

______7. Add the following line to your sendmail aliases file:

ops535: /tmp/ops535.mail

Use vi to create a new file called “test.mesg” in your home directory with the following contents:

Every aliases file must have an alias for postmaster that will expand to the name of a real user. Mail problems encounter by the mail- daemon is always sent to postmaster.

Save both files and execute the “newaliases” and the sendmail command:

/usr/sbin/sendmail v ops535 < /tmp/test.mesg

Record the output of the above command (use the back of this page if you need more space).

______

______

8. Check the /tmp directory for the file “ops535.mail” and determine the following:

(a) Who is the owner of the file /tmp/ops535.mail? ______(b) Who has read permission on that file? ______() What is the “Return Path” indicated in the message header? ______(d) What is the “Message ID”?______

9. Edit your sendmail aliases file and add your login name to the “postmaster” aliases list. After you save the change to your sendmail aliases file, issue the following command:

/usr/lib/sendmail bi

and record the output.

______Which command has the same function as the command “/usr/lib/sendmail -bi”?

______Issue the following command to determine who will received messages send to postmaster.

______10. Send a test message to the user “postmaster” with the following command:

/usr/sbin/sendmail v postmaster < /tmp/test.mesg

OPS535 Lab – Sendmail Part 1 November 2009 Page 3 of 6 Record the last 10 lines from the above command. ______

11. Login to another virtual terminal with your login account name. Is there any new mail for you? What is the message ID of the ?

______Sendmail's mail queue 12. Change to sendmail's configuration directory and execute the following command and record the output:

grep QueueDirectory sendmail.cf

______Enter the command “mailq” and “mailq -Ac” as root and record the outputs:

______

______13. The output of the above command indicates the directory used by sendmail to store outgoing messages that need to be transferred later. Does regular user has access to this directory?

Directory name:______

Directory Permission: ______

14. In general, sendmail does not deliver messages directly to local user's mail box. Sendmail calls other programs (mailers) to perform local delivery. To find out the name of the local delivery agent(s) known by sendmail, try the following command:

grep ^Mlocal sendmail.cf

According to the output from the above command,

Name of local delivery agent : ______

15. Make sure that your machine CAN NOT reach out to . Issue the following command (as root) and record the output:

OPS535 Lab – Sendmail Part 1 November 2009 Page 4 of 6 /usr/sbin/sendmail bv [email protected]

______

______Is the above email address deliverable by your “sendmail”?

______

If your sendmail can handle the above email address, issue the following command and record the output:

/usr/sbin/sendmail v [email protected] < /tmp/test.mesg

______

______

______

______

______

______

16. Issue the command “mailq Acand mailq and record the entire output. ______

______

______

______

______

______

What is the name of the queue directory? ______

How many queue directories are there? ______If there are messages in the queue, determine the following information for the 1st message on the output list:

Q-ID (message id): ______Size: ______

Queue Time: ______

Sender/Recipient:______

OPS535 Lab – Sendmail Part 1 November 2009 Page 5 of 6 17. Issue the command /usr/sbin/sendmail bp. Compare the output with the command mailq.

The output from the two commands are: ______

Make sure that you are login as “root”. Go to the queue directory and use “ls -l ” to display the files in that directory. Files in this directory should be shown up in pairs: one start with “d” and the other with “q”. What information is stored in those “d” and “q” files?

“d” file: ______

“q” file: ______

What are the string of characters after the letter “d” and “q” represent?

______

Remove one pair of those file and then execute the command “mailq” again. Compare the output with the previous output and explain the differences.

______

______

______

Questions: 1. What is the file own and file permission of the file /tmp/ops535.mail? 2. What is the absolute path and access permission of directory used by sendmail to store outgoing messages? 3. What command would you use to check whether a specific email address is deliverable by sendmail? 4. What are the sting of characters after the letter “d” and “q” of name of the files in the mail queue? 5. How would you delete an going message which is sitting in the queue directory?

Answer the above questions and submit to your instructor by the due date.

OPS535 Lab – Sendmail Part 1 November 2009 Page 6 of 6