Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 obv. 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?

UPDATE:

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.
share|improve this question
3  
I am reminded of this. ibiblio.org/harris/500milemail.html –  Tom O'Connor Jan 8 '12 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? –  Simon Jan 8 '12 at 22:07
    
Do you relay all emails to a smarthost, or do both servers send mail directly over the internet? –  Mathias R. Jessen Jan 8 '12 at 23:22
    
Please edit the question and copy-paste what you see in the sendmail logs. –  adamo Jan 9 '12 at 7:24

3 Answers 3

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.

share|improve this answer
    
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 –  Simon Jan 11 '12 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. –  SimonJGreen Jan 11 '12 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?

share|improve this answer
    
:) 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. –  Simon Jan 11 '12 at 11:48
up vote 0 down vote accepted

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 :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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