San Francisco

dave spink toolset




SENDMAIL:

OVERVIEW LOGS SENDING MESSAGES SMTP TEST


THE PROJECT

We needed reliable mail delivery to support the core applications installed on Unix, the obvious choice for us was Sendmail.


OVERVIEW

Sendmail Local Delivery
A message from serverA "/usr/lib/sendmail -v spi0004@serverB.cpships.com" will first be sent to the local sendmail daemon running on serverA. The local sendmail daemon establishes a SMTP connection to serverB. If the user "spi0004" exists on serverB the sendmail server accepts the message, else an error "user unknown" is returned to serverA. The /etc/mail/aliases file on serverB is checked for aliases entries, for example, the alias entry of "spi0004:spi0004,david.spink@cpships.com" results in the email being forwarded onto cpships.com mail servers. If no aliases exists the server delivers mail into the local mailbox of user "spi0004" on serverB. Mail may then be read by the user using pop3 or some other service.

Sendmail as a Forwarder
Our sendmail servers are configured to deliver mail on behalf of other servers in our a domain - a termed called "forwarder". The business application establish a SMTP connection to our sendmail server. The sendmail service receives and queues the message(s). The daemons work the queue by extracting the message header and performing mail record lookups via DNS in order to determine the recipients mail server. Once the IP address of the recipients mail server is known the sendmail service establishes a connection and delivers the message on behalf of the applicaion.



LOGS

Understanding Mail Logs
The following log file extract shows a message accepted and delivered by sendmail. The first entry is saying a user "remown" on server c2pr0001 is asking sendmail on server d1pr0004 to deliver a message. The sendmail process accepts the messages, queues the message, and then checks DNS for a MX record cpships.com i.e. the mail server that can deliver the message to "Monique Sullivan". The status of "Sent" indicates the mail has been delivered to "tpaexfe.ad.cpships.corp". The "Queued mail for delivery" in this example is the response from the "tpaexfe.ad.cpships.corp" mail server, some mail server simply respond "Accepted".

Aug 29 20:27:11 d1pr0004 sendmail[26176]: [ID 801593 mail.info] k7TKRB926176: 
from=<HelpdeskMU@CPShips.com>, size=1938, class=0, nrcpts=1, 
msgid=<remown@c2pr0001.cpships.com> proto=ESMTP, daemon=MTA, relay=[10.70.80.116]

Aug 29 20:27:11 d1pr0004 sendmail[26178]: [ID 801593 mail.info] k7TKRB926176:
to=<Monique.Sullivan@cpships.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp,
pri=121938, relay=tpaexfe.ad.cpships.corp. [10.152.38.168], dsn=2.0.0, 
stat=Sent (<remown@c2pr0001.cpships.com> Queued mail for delivery)

The following extract show the mail server "bdp" refuses connection from our sendmail server.

Aug 29 14:44:38 d1pr0004 sendmail[18374]: [ID 801593 mail.info] k7OEWm909422:
to=<CPETERS@BDP.COM>, delay=5+00:11:49, xdelay=00:00:01, mailer=esmtp, pri=43410934,
relay=bdp.com. [66.116.109.62], dsn=4.0.0, stat=Deferred: Connection refused by bdp.com.

Aug 29 14:44:38 d1pr0004 sendmail[18374]: [ID 801593 mail.info] k7OEWm909422:
k7TEf0A18374: sender notify: Cannot send message for 5 days

The following message sent from Exchange and returned non deliverable first appears to be a problem with the server "tpaexgw01". In fact the problem is with the mail server at "gentiva.com" which replied with the error message. The server "tpaexgw01" received the error message.

Our message did not reach some or all of the intended recipients.
The following recipient(s) could not be reached:
joe.good@gentiva.com on 8/31/2006 10:41 AM
<tpaexgw01.cpships.com> #2.1.0 smtp; 452 4.3.1
Unable to accept message because the server is out of disk space.


SENDING MESSAGES

Send a test message via the sendmail program.

# /usr/lib/sendmail -v david.spink@cpships.com

Sending mail attachments.

# /usr/bin/uuencode file.txt file.txt | mailx -s "Documents" david.spink@cpships.com

Making sense of mail queues.

# cd /var/spool/mqueue
# ls *BGCdrP21777
     dfg.....< is body of messages
     qgf.....< is header of messages
     xfg.....< is attachment

Changing the name of the sender.

#/usr/lib/sendmail -F ecommvss@cpships.com david.spink@cpships.com
Subject: Booking
Your booking ZZZ is complete.
.

Make changes to the aliases file and apply via "newalias" command.

# /etc/mail/aliases
# newaliases


SMTP TEST

To determine the version of sendmail.

# /usr/lib/sendmail -d0 -bt < /dev/null | grep -i Version

Sending a test message by establishing a SMTP connection on port 25.

telnet uxsmpr02.nam.pwcinternal.com 25 
helo ustpa3ifsec01.nam.pwcinternal.com
mail from: <EMC_Control_Center@us.pwc.com>
rcpt to: <david.r.spink@us.pwc.com>
data
Subject: Hello David
This is a test message.
.
quit