I'm trying to send email from PHP using mail(). I have complete access to both servers. No unusual iptables rules on either (nothing blocking a default install of sendmail)

I installed sendmail on the one server a couple of years ago (Ubuntu 10.10) and that sends mail from PHP just fine. The new server (Ubuntu 10.04, set up this week) will not send mail - or it's trying, but every recipient is refusing to receive.

I've checked out the sendmail logs on the new server and it's showing all of the MX servers of the recipient domains are Connection refused...

There's no differences in the set up of these servers. They've got the default sendmail install. A standard LAMP stack. They're on different IPs entirely, but they operate under the same domain (although, obviously, different machines on the domain).

The only thing I can think is that the reverse DNS that is set up for the new server is not being accepted by the spam filter on the recipient MX servers. Is that possible? I've already put in a request to get the reverse DNS changed to something more suitable for the domain of the new server.

The older server is behind a NAT router, so the IP address that email appears to come from when sending from the old server resolves to a domain name that 'correctly' represents the server... but the new server's IP is attached directly to the server, but the current rDNS resolves to a completely different domain.

Is there anything else I could be missing?


A sample /var/log/mail.log row:

Jan 11 12:16:03 ernesto sm-mta[1177]: q071CKnQ002371:
to=<xxx@xxx.xxx>, ctladdr=<www-data@my.server.com> (33/33), delay=4+11:03:43,
xdelay=00:00:00, mailer=esmtp, pri=58080351, relay=aspmx3.googlemail.com.,
dsn=4.0.0, stat=Deferred: Connection refused by aspmx3.googlemail.com.
  • 4
    I am reminded of this. ibiblio.org/harris/500milemail.html Jan 8, 2012 at 21:43
  • @tom-oconnor Cracking story! :) although the versions of sendmail I'm using are different, the on e on the new server is newer than the version used on the old server. Is there anything in particular I should look out for?
    – simonhamp
    Jan 8, 2012 at 22:07
  • Do you relay all emails to a smarthost, or do both servers send mail directly over the internet? Jan 8, 2012 at 23:22
  • Please edit the question and copy-paste what you see in the sendmail logs.
    – adamo
    Jan 9, 2012 at 7:24

3 Answers 3


Solved! It turned out that the hosting provider had some trial account blocks in place to stop abuse. Apparently these would normally be lifted once new customers go through authentication (which I've done) but they weren't. Thankfully they have now been and I can send email perfectly.

So the lesson here: don't assume anything! Go back to your provider first to check with them if anything could be hindering what you're up to.

Sorry to have troubled you fine people. Thank you for all of your suggestions. They all helped find the answer in the end :)


Check your outbound connectivity by trying to connect to an external mail server manually. Simplest way is probably to run telnet aspmx.l.google.com 25 and see if you make contact.

If that works then it's down to sendmail configuration.

Being as this is Ubuntu, I'd be really tempted to apt-get install postfix, choose the correct option from the wizard, and let it sort itself out! Unless you have a real good reason to use sendmail (They are almost 100% compatible in terms of CLI, PHP, etc) then install Postfix.

  • I've tried to telnet from the new server to Google's MX server, but it won't connect... "Connection refused", but I can connect successfully from the old server. They are in different locations mind you, on different networks
    – simonhamp
    Jan 11, 2012 at 11:33
  • In that case, this is without a doubt an outbound network issue. Can you ping www.google.com from this server? Assuming the answer is yes then there's a firewall blocking port 25 outbound. SOME ISPs block SMTP outbound to anything other than their own mail servers. Jan 11, 2012 at 15:03

It is a network issue. "connection refused" means connection refused. So nothing with the software but with the network.

Start with network problem checks. Ping, traceroute, telnet, route, iptables and others come to mind. First start: Is the network cable plugged in?

  • :) this is a virtual server, net access is fine (as I have to SSH into it). I can ping Google's MX servers, for example, but can't telnet to them.
    – simonhamp
    Jan 11, 2012 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.