Help - Search - Members - Calendar
Full Version: Mail Issues and How to Troubleshoot Them
The Planet Forums > System Administration > Mail Hosting
bsykes
We got a lot of tickets in with questions pertaining to email problems, what they mean, and also how to fix them. Nearly all of this will be referring to Exim, but the concepts in here pertain to other MTA's as well.

The first thing that usually gives people fits with email, is that it is so closely tied to proper DNS resolution. You need to make sure that your hostname is resolvable, and also matches your reverse record. Some email servers on the Internet are very picky about this, and will reject mail coming to them, if the forward and reverse records do not match. We here at Servermatrix do not automatically setup reverse records, so you will have to submit a DNS Change Request through Orbit to get this done.

Another problem that we see a lot is people getting Error 550 messages when trying to send mail. 550 is Administrative Prohibition, which just means that what you are trying to do is against "the rules" and the message is being rejected outright. There are different 550 messages such as "You are not allowed to relay through this server ..." which generally indicates that either you have not checked your POP account in the past 30 minutes before trying to send mail, or you do not have authenticated SMTP setup in your mail client. Another possibility is that you are on a serverwide list of hosts that are blocked from sending, but this is somewhat unlikely. The 550 error will generally tell you why it is being prohibited.

Now, let's delve into some tools that come standard with Exim that can help you troubleshoot any delivery errors you are seeing.

Obviously the first thing you can do, is to open up /var/log/exim_mainlog and pick through it with your favorite text editor. Vi is the only correct text editor, however this is a matter of almost religious preference. icon_wink.gif

However, picking through this log is sometimes tedious as there are generally a lot of lines in there not relating to what you are looking for. Fear not, to the rescue is "exigrep". So, ever have a customer who is claiming that somebody isn't able to send/receive email? Hate to open up exim_mainlog in vi and pick through it? Try exigrep. It's included with the default installation of exim and is VERY useful. The reason for this is that it will look for whatever text, match that to a message-ID, and then spit out all the lines pertaining to that message. An example:


root@cpdemo [~]# exigrep 1BbLM3-0007fA-0v /var/log/exim_mainlog
2004-06-18 10:32:35 1BbLM3-0007fA-0v <= root@cpdemo.theplanet.com U=root P=local S=1037
2004-06-18 10:32:37 1BbLM3-0007fA-0v => /dev/null <devnull@cpdemo.theplanet.com> R=system_aliases T=**bypassed**
2004-06-18 10:32:37 1BbLM3-0007fA-0v Completed


-OR-

root@cpdemo [~]# exigrep inspirem@cpdemo.theplanet.com /var/log/exim_mainlog
2004-06-14 00:00:00 1BZjZg-000750-Ch <= inspirem@cpdemo.theplanet.com U=inspirem P=local S=597
2004-06-14 00:00:00 1BZjZg-000750-Ch == truei773@yahoo.com R=defer_router defer (-1): All deliveries are handled by MailScanner
2004-06-14 00:00:03 1BZjZg-000750-Ch => truei773@yahoo.com R=lookuphost T=remote_smtp H=mx1.mail.yahoo.com [64.157.4.78]
2004-06-14 00:00:03 1BZjZg-000750-Ch Completed

2004-06-15 00:00:01 1Ba63E-0004gD-US <= inspirem@cpdemo.theplanet.com U=inspirem P=local S=597
2004-06-15 00:00:01 1Ba63E-0004gD-US == truei773@yahoo.com R=defer_router defer (-1): All deliveries are handled by MailScanner
2004-06-15 00:00:04 1Ba63E-0004gD-US => truei773@yahoo.com R=lookuphost T=remote_smtp H=mx1.mail.yahoo.com [64.156.215.19]
2004-06-15 00:00:04 1Ba63E-0004gD-US Completed

etc ...

Notice that if you are looking or things that are listed in multple emails (ie. email addresses, sending hosts, etc ...) it will seperate out the different emails for you to find them.

Our next tool in the Exim Roundup, is exiwhat. Typing this will show you what each running instance of exim is doing at that particular moment:

root@cpdemo [~]# exiwhat
2118 daemon: -q1h, listening for SMTP on port 25 (IPv4)
2130 daemon: no queue runs, listening for SMTPS on port 465 (IPv4)
31640 handling incoming connection from [67.19.0.37]


Provided you don't have MailScanner installed, the next tool (it's actually a switch), will show you how exim believes a message should be delivered. The usage is:

exim -bt <email address>


The next switch to know is:

exim -bh <ip address>


This will create a fake SMTP session which appears to be from <ip address>. Not only that, but it also spits out what exim is doing behind the scenes, and also what it would normally log. Now, bear in mind that this will not actually inject a message into the queue, nor will it actually log anything. This does however require knowledge of SMTP commands, but they are fairly easy. I have highlighted them in bold below for easier reading:

root@cpdemo [/var/spool/exim/input]# exim -bh 216.87.139.155

**** SMTP testing session as if from host 216.87.139.155
**** but without any ident (RFC 1413) callback.
**** This is not for real!

>>> host in host_lookup? no (option unset)
>>> host in host_reject_connection? no (option unset)
>>> host in sender_unqualified_hosts? no (option unset)
>>> host in recipient_unqualified_hosts? no (option unset)
>>> host in helo_verify_hosts? no (option unset)
>>> host in helo_try_verify_hosts? no (option unset)
>>> host in helo_accept_junk_hosts? yes (matched "*")
220-cpdemo.theplanet.com ESMTP Exim 4.34 #1 Fri, 18 Jun 2004 16:05:31 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
helo bsykes-2.august.net
>>> bsykes-2.august.net in helo_lookup_domains? no (end of list)
250 cpdemo.theplanet.com Hello bsykes-2.august.net [216.87.139.155]
mail from: hootieben@bsykes-2.august.net
250 OK
rcpt to: inspirem@cpdemo.theplanet.com
>>> using ACL "check_recipient"
>>> processing "accept"
>>> check hosts = :
>>> host in ":"? no (end of list)
>>> accept: condition test failed
>>> processing "warn"
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}/config.pck}}} {yes}{no}}
>>> = no
>>> warn: condition test failed
>>> processing "accept"
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}/config.pck}}} {yes}{no}}
>>> = no
>>> accept: condition test failed
>>> processing "warn"
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}_${lc:$domain}/config.pck}}} {yes}{no}}
>>> = no
>>> warn: condition test failed
>>> processing "accept"
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}_${lc:$domain}/config.pck}}} {yes}{no}}
>>> = no
>>> accept: condition test failed
>>> processing "require"
>>> check verify = sender
>>> hootieben@bsykes-2.august.net in "nobody@lsearch;/etc/localdomains"? no (end of list)
>>> hootieben@bsykes-2.august.net in "cpanel@lsearch;/etc/localdomains"? no (end of list)
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing hootieben@bsykes-2.august.net
>>> bsykes-2.august.net in "lsearch;/etc/localdomains"? no (end of list)
>>> bsykes-2.august.net in "! +local_domains"? yes (end of list)
>>> calling lookuphost router
>>> 216.87.139.155 in "0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24"? no (end of list)
>>> routed by lookuphost router
>>> ----------- end verify ------------
>>> require: condition test succeeded
>>> processing "accept"
>>> check domains = +local_domains
>>> cpdemo.theplanet.com in "lsearch;/etc/localdomains"? yes (matched "lsearch;/etc/localdomains")
>>> cpdemo.theplanet.com in "+local_domains"? yes (matched "+local_domains")
>>> check verify = recipient
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing inspirem@cpdemo.theplanet.com
>>> cpdemo.theplanet.com in "! +local_domains"? no (matched "! +local_domains" - cached)
>>> cpdemo.theplanet.com in "! +local_domains"? no (matched "! +local_domains" - cached)
>>> cpdemo.theplanet.com in "! +local_domains"? no (matched "! +local_domains" - cached)
>>> cpdemo.theplanet.com in "lsearch;/etc/userdomains"? no (end of list)
>>> cpdemo.theplanet.com in "! lsearch;/etc/userdomains"? yes (end of list)
>>> cpdemo.theplanet.com in "lsearch;/etc/localdomains"? yes (matched "lsearch;/etc/localdomains")
>>> calling virtual_aliases_nostar router
>>> virtual_aliases_nostar router declined for inspirem@cpdemo.theplanet.com
>>> cpdemo.theplanet.com in "lsearch;/etc/userdomains"? no (end of list)
>>> cpdemo.theplanet.com in "lsearch;/etc/userdomains"? no (end of list)
>>> cpdemo.theplanet.com in "lsearch;/etc/localdomains"? yes (matched "lsearch;/etc/localdomains")
>>> cpdemo.theplanet.com in "lsearch;/etc/localdomains"? yes (matched "lsearch;/etc/localdomains")
>>> calling virtual_aliases router
>>> virtual_aliases router declined for inspirem@cpdemo.theplanet.com
>>> calling system_aliases router
>>> system_aliases router declined for inspirem@cpdemo.theplanet.com
>>> calling local_aliases router
>>> local_aliases router declined for inspirem@cpdemo.theplanet.com
>>> cpdemo.theplanet.com in "! lsearch;/etc/userdomains"? yes (end of list)
>>> cpdemo.theplanet.com in "! lsearch;/etc/userdomains"? yes (end of list)
>>> calling localuser router
>>> routed by localuser router
>>> ----------- end verify ------------
>>> accept: condition test succeeded
250 Accepted
Data
354 Enter message, ending with "." on a line by itself
From: Ben Sykes <hootieben@bsykes-2.august.net>
Subject: Test
>>> host in ignore_fromline_hosts? no (option unset)

Test.
.

>>> using ACL "check_message"
>>> processing "require"
>>> check verify = header_sender
>>> verifying From: header address Ben Sykes <hootieben@bsykes-2.august.net>
>>> hootieben@bsykes-2.august.net in "nobody@lsearch;/etc/localdomains"? no (end of list)
>>> hootieben@bsykes-2.august.net in "cpanel@lsearch;/etc/localdomains"? no (end of list)
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing hootieben@bsykes-2.august.net
>>> bsykes-2.august.net in "lsearch;/etc/localdomains"? no (end of list)
>>> bsykes-2.august.net in "! +local_domains"? yes (end of list)
>>> calling lookuphost router
>>> 216.87.139.155 in "0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24"? no (end of list)
>>> routed by lookuphost router
>>> require: condition test succeeded
>>> processing "accept"
>>> accept: condition test succeeded
LOG: 1BbQZP-00005P-Gg <= hootieben@bsykes-2.august.net H=(bsykes-2.august.net) [216.87.139.155] P=smtp S=264
250 OK id=1BbQZP-00005P-Gg

**** SMTP testing: that is not a real message id!


Ta da! There are some fancy tools to use if you are ever having email issues. Have fun.
spiffikins
thank you!

this is a great article, and was very helpful to me today - so glad I found it!
troxelso
Thanks this was very useful!
cmariomej
Damn! I just post a question here and i found this article that maybe is the help I was looking for... hopefully it will. Thanx for the great guide!!

Cheers!!
houseoftech
Good article. I found some more exim commands online but not what I was needing. Is there a way to delete all messages for a specific recipient?

-Corie
zien4host
thats great cool.gif

thank you very much
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.