Can’t send email. (That old chest nut again)

I have Installed Ubuntu 8.04 server and webmin/virtualmin/usermin(install.sh). Ubuntu 8.04 and install.sh were installed 5 days ago and at the end of the installation the server record were updated at my registration company. The installation Want well (no errors). I have set up two virtual server. Both sites are available from the internet (when you type www.mysite.com you get the site).

Now to the problem.

Email.
If I send email from any email address on the server to any other email address on the server the email is received as expected.
If the server receives email from any email address in the outside world, the email is delivered to the correct email address on my server.

The email address that I am attempting to send to are correct addresses. But If I try to send email out to any email address in the outside world it gets trapped in the mail Queue with the error.

Host or domain name not found. Name service error for name=receiverssite.com type=MX: Host not found, try again

Note name=receverssite.com this message has removed the person to whom the email was addressed. I am not sure if this is normal for this message or it points to a underlying problem.

I have looked in the logs but I don’t see any thin that even remotely points to what the problem could be.

From the mail.log

May 5 11:53:49 myserver postfix/smtpd[21354]: connect from unknown[95.181.19.7]
May 5 11:53:51 myserver postfix/smtpd[21354]: 0CE78673D: client=unknown[95.181.19.7]
May 5 11:53:52 myserver postfix/cleanup[21358]: 0CE78673D: message-id=20100505105302.2796.qmail@95-181-19-7.goodline.info
May 5 11:53:52 myserver postfix/qmgr[6471]: 0CE78673D: from=allan@myfirstsite.com, size=2421, nrcpt=1 (queue active)
May 5 11:53:52 myserver postfix/smtpd[21354]: disconnect from unknown[95.181.19.7]
May 5 11:57:12 myserver postfix/anvil[21356]: statistics: max connection rate 1/60s for (smtp:95.181.19.7) at May 5 11:53:49
May 5 11:57:12 myserver postfix/anvil[21356]: statistics: max connection count 1 for (smtp:95.181.19.7) at May 5 11:53:49
May 5 11:57:12 myserver postfix/anvil[21356]: statistics: max cache size 1 at May 5 11:53:49
May 5 11:57:43 myserver spamc[21371]: connect to spamd on 127.0.0.1 failed, retrying (#1 of 3): Connection timed out
May 5 11:59:50 myserver postfix/qmgr[6471]: 41AB267C0: from=myname@myfirstsite.com, size=774, nrcpt=1 (queue active)
May 5 11:59:50 myserver postfix/qmgr[6471]: 2D57467CC: from=myname@myfirstsite.com, size=730, nrcpt=1 (queue active)
May 5 11:59:50 myserver postfix/qmgr[6471]: 5A3F96773: from=myname@mysecondsite.com, size=760, nrcpt=1 (queue active)
May 5 11:59:50 myserver postfix/qmgr[6471]: 5851F67C4: from=myname@mysecondsite.com, size=754, nrcpt=1 (queue active)
May 5 12:00:43 myserver postfix/smtp[21467]: 41AB267C0: to=sentto1@receivers1site.com, relay=none, delay=92528, delays=92475/0.06/53/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=receivers1site.com type=MX: Host not found, try again)
May 5 12:00:43 myserver postfix/smtp[21468]: 2D57467CC: to=me.outside@Safe-mail.net, relay=none, delay=92109, delays=92056/0.07/53/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=Safe-mail.net type=MX: Host not found, try again)
May 5 12:00:43 myserver postfix/smtp[21469]: 5851F67C4: to=sentto1@receivers1site.com, relay=none, delay=93723, delays=93670/0.09/53/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=receivers1site.com type=MX: Host not found, try again)
May 5 12:00:43 myserver postfix/smtp[21470]: 5A3F96773: to=sentto1@receivers1site.com, relay=none, delay=93823, delays=93770/0.1/53/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=receivers1site.com type=MX: Host not found, try again)
May 5 12:00:53 myserver spamc[21371]: connect to spamd on 127.0.0.1 failed, retrying (#2 of 3): Connection timed out
May 5 12:04:04 myserver spamc[21371]: connect to spamd on 127.0.0.1 failed, retrying (#3 of 3): Connection timed out
May 5 12:04:05 myserver spamc[21371]: connection attempt to spamd aborted after 3 retries
May 5 12:04:05 myserver postfix/local[21359]: 0CE78673D: to=myname.mysite@myserver.myfirstsite.com, orig_to=allan@myfirstsite.com, relay=local, delay=615, delays=1.6/0.03/0/613, dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME)
May 5 12:04:05 myserver postfix/qmgr[6471]: 0CE78673D: removed
May 5 12:13:15 myserver dovecot: imap-login: Login: user=<myname.mysite>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
May 5 12:13:16 myserver last message repeated 4 times
May 5 12:13:16 myserver dovecot: IMAP(myname.mysite): Connection closed
May 5 12:13:16 myserver last message repeated 4 times

Thanks
Allan

Hi Allan,

That sort of issue seems to point to a problem with DNS.

Are you sure what’s in your /etc/resolv.conf file is correct?

It sounds like your server is having trouble resolving hostnames and such… which is something that wouldn’t need to happen for locally hosted domains.

-Eric

Hi Eric

below is form my resolv.conf (Note # lines don’t exist).

localhost

nameserver 127.0.0.1

my internal Ip address

nameserver 192.xxx.xxx.xxx

my external IP address

nameserver 230.xxx.xxx.xxx

Public DNS Server

nameserver 8.8.8.8

my domain

domain mydomain.com

Try commenting out all but the “nameserver 127.0.0.1” line, restart Postfix with “/etc/init.d/postfix restart”, and see if that does the trick.

There’s no real reason to list all of those IP’s in there… and in particular, having your external IP listed may be causing the trouble, as most routers don’t know how to handle a request for the routers external IP from the internal LAN.

-Eric

Hi Eric

my resolv.conf now looks like

nameserver 127.0.0.1
#nameserver 192.xxx.xxx.xxx

nameserver 230.xxx.xxx.xxx

nameserver 8.8.8.8

domain mydomain.com

But now mail that arrives in the queue is given a status of

<cite>Host or domain name not found. Name service error for name=Safe-mail.net type=MX: Host not found, try again</cite>

by the MAILER-DAEMON, and is set to be returned. But it is not returned it just sits in the Queue. Also I can no longer send or receive email at all (even from an email address on the server to any other email address on the server) and when is sent from an email address on the server to any other email address on the server the email just disappears

Thanks
Allan

Okay, that’s the same error you were getting, so it still sounds like you’re seeing a DNS or related problem of some kind.

Do you get a response of some kind if you type, say, “host google.com” on your server? Does it show you a list of IP addresses?

There’s a few config files associated with BIND, it’s possible something in one of them is causing problems… what are the contents of /etc/bind/named.conf.options and /etc/bind/named.conf.local?

-Eric

Hi Eric

Do you get a response of some kind if you type, say, “host google.com” on your server? Does it show you a list of IP addresses?

Initially no but after some reading http://www.oreillynet.com/pub/a/network/excerpt/dnsbindcook_ch07/index.html if I opened up my firewall like this (if anyone thinks there is a better way to handle the firewall rules please let me know)

Incoming packets (INPUT)
Accept If protocol is TCP and destination port is 1024:65535 and source port is 53
Accept If protocol is UDP and destination port is 1024:65535 and source port is 53
Accept If protocol is TCP and destination port is 53 and source port is 1024:65535
Accept If protocol is UDP and destination port is 53 and source port is 1024:65535

Outgoing packets (OUTPUT)
Accept If protocol is TCP and destination port is 53 and source port is 1024:65535
Accept If protocol is UDP and destination port is 53 and source port is 1024:65535
Accept If protocol is TCP and destination port is 1024:65535 and source port is 53
Accept If protocol is UDP and destination port is 1024:65535 and source port is 53

I get

host google.com
google.com has address 66.102.11.104
google.com mail is handled by 300 google.com.s9b1.psmtp.com.
google.com mail is handled by 100 google.com.s9a1.psmtp.com.
google.com mail is handled by 200 google.com.s9a2.psmtp.com.
google.com mail is handled by 400 google.com.s9b2.psmtp.com.

However email sent within the server are still lost with out a trace and all email sent to the server are now returned to the sender with the following message

From MAILER-DAEMON@server1 (Mail Delivery System)
To me@Safe-mail.net
Date Fri, 7 May 2010 11:17:15 +0800 (WST)
Subject Undelivered Mail Returned to Sender

This is the mail system at host server1.company.com.au.

I’m sorry to have to inform you that your message could not
be delivered to one or more recipients. It’s attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

               The mail system

myemail.MailboxNamePrefix@server1 (expanded from
myemail@Domain.com.au): Host or domain name not found. Name
service error for name=server1 type=A: Host not found

/etc/bind/named.conf.options

options {
directory “/var/cache/bind”;

// If there is a firewall between you and nameservers you want
// to talk to, you might need to uncomment the query-source
// directive below.  Previous versions of BIND always asked
// questions using port 53, but BIND 8.1 and later use an unprivileged
// port by default.

// query-source address * port 53;

// If your ISP provided one or more IP addresses for stable 
// nameservers, you probably want to use them as forwarders.  
// Uncomment the following block, and insert the addresses replacing 
// the all-0's placeholder.

// forwarders {
// 	0.0.0.0;
// };

auth-nxdomain no;    # conform to RFC1035
listen-on-v6 { any; };

};

/etc/bind/named.conf.local?

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include “/etc/bind/zones.rfc1918”;

zone “virtual1.com.au” {
type master;
file “/var/lib/bind/binaryone.com.au.hosts”;
allow-transfer {
127.0.0.1;
localnets;
};
};
zone “virtual2.com.au” {
type master;
file “/var/lib/bind/abcwcs.com.au.hosts”;
allow-transfer {
127.0.0.1;
localnets;
};
};
zone “xxx.xxx.xxx.230.in-addr.arpa” {
type master;
file “/var/lib/bind/230.xxx.xxx.xxx.rev”;
};

Additionally you could be right about bind. When I restart bind or the server it stops for around 5 minutes, then returns the rndc: message.

/etc/init.d/bind9 restart

  • Stopping domain name service… bind
    rndc: connect failed: 127.0.0.1#953: timed out
    …fail!
  • Starting domain name service… bind
    …done.

Thanks for your help
Allan

Hi Eric

I finally figured this out. It turns out to be a number of problems, all minor but together the server would not work. There were several missing firewall rules (my bad) and once included every thing except mail was working. Then Hostname has been bothering me for some time because it just looked wrong. I corrected it with the instructions below.

  1. Check your Hostname has the correct information.

    a. Goto webmin> Others> Command Shell>

    i.	when the command shell loads in the text field next to “execute command” 
    
    ii.	Enter “hostname --fqd” it should return “server1.company.com.au” 
    
    iii.	Then enter “hostname -s” it should return “server1” 
    
    iv.	Then enter “hostname -f” it should return “server1.company.com.au” 
    
    v.	If all above is correct continue if not you will have to correct it. 
    

    b. Next goto webmin> Networking> Network Configuration> Hostname and DNS Client>

    c. Check that the Hostname field has your hostname “server1.company.com.au”.

    i.	If the Hostname field does not have your hostname “server1.company.com.au” correct it 
    
    ii.	Below the Hostname field is a checkbox “Update hostname in host addresses if changed?” uncheck this check box.
    
    iii.	NOTE: You must uncheck the check box 
    
    iv.	Check that you have unchecked the check box and if you have click save.
    
    	(1)	NOTE: If you do not uncheck the check box you will have multiple entries in several configuration files and your server will not work.
    

Once that was fixed the email all started to be delivered properly. As far as I can tell at this stage the server is now working properly now including email. Time will tell.

The instructions above are an extract from the tutorial that I have been. I would like to post the entire tutorial some where here so that others can benefit. Where would you suggest?

Thanks
Allan

Hi Eric

When you go to webmin> Networking> Network Configuration> Hostname and DNS Client>. The Hostname field has your hostname “server1.company.com.au” and below the Hostname field is a checkbox “Update hostname in host addresses if changed?”.

If the check box is uncheck and you click save which files are upated?

Sorry, I’m not sure what files are updated… it’s certainly the files related to what hostname is set when the server boots. It may possibly include /etc/hosts and /etc/postfix/main.cf, though you’d have to test that to be sure :slight_smile:

-Eric

Hi Eric

I think there has to be another file involved here, emphasis on the I think. The reason is when I was having my mail problem the Hostname field on the Hostname and DNS Client page had “server1”. If I corrected it and saved while the “Update hostname in host addresses if changed?” check box is checked then one or both of the files you mentioned above are updated with double entries of “server1.company.com.au” while the hostname field on the Hostname and DNS Client page has a single entry.

Yet when I unchecked the check box, updated the Hostname field and saved, the two files you mentioned above and the hostname field are then correct. This leads me to be leave there is another file involved where the Hostname field on the Hostname and DNS Client page gets some of its information. If I am correct then some times these files and the Hostname field can become out of sync which was my case. Also there seems to be quite a few others with the same problem. That is why I would be interested to know where the Hostname field gets it’s info from.

Thanks
Allan