SMTP Lab Reference: RFC821 Simple Mail Transfer Protocol SIMPLE MAIL TRANSFER PROTOCOL 1. INTRODUCTION The objective of Simple Mail Transfer Protocol (SMTP) is to transfer mail reliably and efficiently. SMTP is independent of the particular transmission subsystem and requires only a reliable ordered data stream channel. Appendices A, B, C, and D describe the use of SMTP with various transport services. A Glossary provides the definitions of terms as used in this document. An important feature of SMTP is its capability to relay mail across transport service environments. A transport service provides an interprocess communication environment (IPCE). An IPCE may cover one network, several networks, or a subset of a network. It is important to realize that transport systems (or IPCEs) are not one-to-one with networks. A process can communicate directly with another process through any mutually known IPCE. Mail is an application or use of interprocess communication. Mail can be communicated between processes in different IPCEs by relaying through a process connected to two (or more) IPCEs. More specifically, mail can be relayed between hosts on different transport systems by a host on both transport systems. - RFC821 Objective: Explore the command/response transaction of the Simple Mail Transfer Protocol This lab consists of three parts. We will first check the version of the SMTP server and make sure that the SMTP port is on. Secondly, we will establish an interactive SMTP session with the local SMTP server and study some of the major SMTP commands. Lastly, we will use the interactive SMTP session to send email to users and mailing list on the local machine. Page 1 of 7
Part I: SMTP Server (1) Login to you NIS server (one of your virtual machine) as a regular user. The default SMTP server installed by RHEL/CentOS is sendmail. Find out which version of the sendmail rpm is installed in your system. : rpm q sendmail Sendmail Version: (2) SMTP server use one of the well known ports. The port number used by SMTP is (3) There are two places (or commands) you can check to see whether a SMTP server is running on your system. The 1 st one is the output of the netstat a command. Look for the SMTP port number under the Local Address column and record the line(s) that contain the SMTP port : (a) : netstat a grep smtp Output: (b) : netstat an grep 25 Output: (4) The other place is the output of the ps ef grep sendmail command. : ps ef grep sendmail Output: (Note: You need a different command if the system is running other SMTP server.) Page 2 of 7
Part II: SMTP commands (5) Login as a regular user and execute the commands under the column and record the output under the column. Do not proceed if the first command does not establish a connection to port 25 on the local host. telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 localhost.localdomain ESMTP... EHLO domain.com NOOP RSET VERB EXPN ops535m VRFY toronto VRFY nobody HELP (6) su to root and backup the file /etc/mail/sendmail.cf to /etc/mail/sendmail.cf.org. (7) While you are still su to root, edit the file /etc/mail/sendmail.cf, change the line: to: O PrivacyOptions=authwarnings,novrfy,noexpn,restrictqrun O PrivacyOptions=authwarnings,restrictqrun Page 3 of 7
(8) Save the changes and restart sendmail server. : service sendmail restart (9) Login as a regular user and execute the commands under the column and record the output under the column. telnet localhost 25 EXPN ops535m VRFY toronto VRFY postmaster EXPN postmaster VRFY mailer daemon EXPN mailer daemon VRFY manager VRFY somebody (10) su to root, backup the file /etc/aliases to /etc/aliases.org and execute the following commands: # echo ops535m: adm,uucp,ftp >> /etc/aliases # newaliases (11) Record the output of the above commands: (12) Login as a regular user and execute the command under the column and record the output under the column. Page 4 of 7
telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 localhost.localdomain ESMTP Sendmail... EXPN ops535m produce the output) VRFY ops535m product the output) (13) In the NIS Lab, you were ask to create user nis101and nis102. Look up the login name from your /etc/passwd file and record them in the following table: User 1 User 2 Login Name UID User Name (The 5 th field of a /etc/passwd record) nis101 nis102 If the 5 th field for nis101 is empty, use the command chfn nis101 to set the Name[] field to Alice. Do the same for nis102 and set it to Bob (14) su to root and execute the following commands: # echo smtp-lab: nis101,nis102 >> /etc/aliases # newaliases (15) Login as a regular user and execute the commands under the column and record the output under the column. telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 localhost.localdomain ESMTP Sendmail... Page 5 of 7
EXPN smtp lab produce the output) VRFY smtp lab produce the output) (16) Compare the results from step 5, 9, 12 and 15 and comment on the results. Question: Would you be able to telnet from your other virtual machines to port 25 on your NIS server and repeat the task in step (9)? If not, what need to be changed on your NIS server to allow other machines to connect to the SMTP server on your NIS server? Page 6 of 7
Part III Sending emails using the SMTP commands (17) Login as a a regular user and connect to the local SMTP server. Use the information in the following table to send email to nis101, nis102, postmaster, ftp, ops535m and smtp lab. From To Message Final Destination of the Message ws.podx.ca nis101 Message for nis101 Test message 1. ws.podx.ca nis102 Message for nis102 Test message 2. ws.podx.ca smtp lab Message for smtp lab Test message 4 ws.podx.net postmaster Message for postmaster Test message 5 ws.podx.net ftp Message for ftp Test message 6 ws.podx.net ops535m Message for ops535m Test message 7 (18) Login as user1, and user2 and check out what messages they received: User Login_name Message received User 1 User 2 (19) Find out who received the messages addressed to postmaster (Test message 5), ftp (Test message 6) and ops535m (Test message 7) (20) Write up a step by step procedure for following tasks: (a) add a new mail alias called sysadmin that includes user1, user2 and your login account name. (b) All email send to postmaster should also be send the new mailing list sysadmin. (21) Once you complete this Lab, show this page to your instructor. Page 7 of 7