SMTP Tips for the System Administrator

Configuration

sendmail.cf
/etc/mail/sendmail.cf on HP-UX
/etc/sendmail.cf on AIX

Smart Relay Host  (DS) - This setting identifies another server that the local server can relay mail to for delivery.

DSmailserver.domain.com

Masquerade (DM) - This setting identifies the domain to be used for the return address of the sender, rather than the actual server and domain name.

DMreplydomain.com

Note:  Normally sendmail.cf will not use DM for root.  This is controlled by the CE setting.  To allow root to sendmail and have it's actual server and domain changed using DM you must change "CE root" to "CE" by itself.

Any changes that are made to the sendmail.cf require that the sendmail service be restarted:

On HP-UX:

/usr/sbin/init.d/sendmail stop
/usr/sbin/init.d/sendmail start

On AIX:

refresh sendmail

Sendmail to multiple recipients from the Command Line

sendmail user1@domain1.com, user2@domain2.com, user3@domain3.com, etc.

Troubleshooting SMTP

1.  Using sendmail to test smtp from the command line

You can test SMTP on a unix server using sendmail from the command line.  Suppose this is the test message you want to send:

Subject:  Test Message

Testing one, two, three

This is the command syntax, and it's results:

SERVER# sendmail -v -f"user1@source.com" user2@destination.com
Subject:  Test Message

Testing one, two, three
.
user2@destination.com... Connecting to mailserver.domain.com. via relay...
220 mailserver.domain.com (IntraStore TurboSendmail) ESMTP Service ready
>>> EHLO server.source.com
250-server.source.com
250-EXPN
250-8BITMIME
250-PIPELINING
250-DSN
250-AUTH=LOGIN
250-AUTH PLAIN CRAM-MD5 SKEY
250-ETRN
250 SIZE 2147483647
>>> MAIL From:<user1@source.com> SIZE=54
250 sender <user1@source.com> OK
>>> RCPT To:<user2@destination.com>
250 recipient <user2@destination.com> OK
>>> DATA
354 Enter mail, end with "." on a line by itself
>>> .
250 Message received and queued
user2@destination.com... Sent (Message received and queued)
Closing connection to mailserver.domain.com.
>>> QUIT
221 Until later server.domain.com


Sendmail is the local program that will use smtp to send the message.  The -v option is verbose, and it will display the communcations with the smtp server.  This is a useful switch that sometimes will display useful error messages for debugging.  The -f option is not required, but will allow you to specify who the email is from.  This is useful if the firewall will only allow certain users to send email to the outside.  This message is from user1 at source.com and it is being sent to user2 at destination.com.  Sendmail will allow you to send any text you want and will only send the text when it finds a period (".") on a line by itself.  By using the keyword Subject:, sendmail will format the email to show "Test Message" in the subject field.

2.  Using Telnet to test SMTP

For more indepth troubleshooting, it is possible to telnet directly into smtp on a unix server.  Once you are connected to smtp, you can send the message by directly interacting with smtp.  This will allow you to see the results of each smtp command that you enter.  Let's assume that you want to send the following message by using telnet with smtp:

Subject:  Test Message

Testing one, two, three

We will assume that this message is from user1@source.com and that it is for user2@destination.com.  Here is the command syntax and it's results:

SERVER# telnet server.domain.com 25
Trying...
Connected to SERVER.
Escape character is '^]'.
220 server.domain.com ESMTP Sendmail 8.9.3 (PHNE_26304)/8.8.6; Thu, 26 Jun 2003 08:58:23 -0400 (EDT)
HELO server.domain.com
250 server.domain.com Hello root@SERVER [10.22.5.24], pleased to meet you
MAIL From:  user1@source.com
250 user1@source.com... Sender ok
RCPT To: user2@destination.com
250 user2@destination.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject:  Test Message
Testing one, two, three
.
250 JAA25742 Message accepted for delivery
QUIT
221 server.domain.com closing connection