I have an Ubuntu server with php and sendmail.
When I use PHP to send an email via sendmail the mail just sits in the sendmail queue forever and never gets sent. Even if I force flush it it still sits in the queue.
What could the cause of this be and how can I fix it?
Thanks.
EDIT: The output of "cat /var/spool/mqueue/qfn82FuSu3009905" is:
V8
T1251906988
K1251927546
N6
P570369
I8/1/121795
MDeferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Fwbs
$_localhost [127.0.0.1]
$rESMTP
$sworld0.com
${daemon_flags}
${if_addr}127.0.0.1
S<[email protected]>
A<>
MDeferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
rRFC822; [email protected]
RPFD:<[email protected]>
H?P?Return-Path: <g>
H??Received: from world0.com (localhost [127.0.0.1])
by world0.com (8.14.3/8.14.3/Debian-6) with ESMTP id n82FuSu3009905
for <[email protected]>; Wed, 2 Sep 2009 08:56:28 -0700
H?x?Full-Name: www-data
H??Received: (from www-data@localhost)
by world0.com (8.14.3/8.14.3/Submit) id n82FuR5T009904;
Wed, 2 Sep 2009 08:56:27 -0700
H??Date: Wed, 2 Sep 2009 08:56:27 -0700
H??Message-Id: <[email protected]>
H??To: [email protected]
H??Subject: Website feedback form
H??MIME=Version: 1.0
H??Content-type: text/html; charset=iso-8859-1
H??From: [email protected]
.
I do not see where anything is going wrong.
EDIT 2:
Well, I can ping the server but not talk to it over telnet, how could that be? I have no firewall running.
root@world0:~# telnet alt4.gmail-smtp-in.l.google.com 25
Trying 72.14.221.114...
telnet: Unable to connect to remote host: Connection timed out
root@world0:~# ping 72.14.221.114
PING 72.14.221.114 (72.14.221.114) 56(84) bytes of data.
64 bytes from 72.14.221.114: icmp_seq=1 ttl=241 time=167 ms
64 bytes from 72.14.221.114: icmp_seq=2 ttl=241 time=171 ms
64 bytes from 72.14.221.114: icmp_seq=3 ttl=241 time=169 ms
64 bytes from 72.14.221.114: icmp_seq=4 ttl=241 time=222 ms
^C
--- 72.14.221.114 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3015ms
rtt min/avg/max/mdev = 167.840/182.722/222.589/23.055 ms
To find out more about the disposition of a message, try this:
You'll see lots of lines like this:
where n82FR6a3019167 is the message ID
Try looking at those files (they're just text files), particularly the one named qn82FR6a3019167 (or whatever your message ID number is. Note: the 'q' before the message ID. You should be able to determine the status of the message, which will hopefully help determine what isn't working properly.
If that doesn't help, you may need to look at the smart relay setting in sendmail.cf. Your PHP server might need to relay mail out through a Smart Relay host.
Next, I would try a manual SMTP session from your PHP server to the Google mail server.
This will hopefully tell you if your IP address is being blocked, or if some SPF (Sender Policy Framework) problem exists, or if you have DNS name mismatches that may be causing your email to be denied or deferred.
I presume you truncated the listing of the details in your reply. Your system really should have a valid hostname with reverse DNS entries for that hostname.
Also, check your /etc/hosts file to ensure that your IP address is listed correctly there. It's pretty common to have hostname mismatches be a problem when relaying email to the internet (at least, in my experience).
Something like:
I found the solution.
My ISP started blocking port 25 by default to stop spammers. A quick call to them opened the port back up and all mail started flowing.
Thank you Joe for your help.
Look at the lines that say
Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com
. They tell you that your server was able to resolve an MX record for gmail.com, but it couldn't connect to the remote server. What happens when you telnet to port 25 on that host from the mail server? You should see something like this (note that I typed "quit"):Do you have any firewall rules in place that would block outbound connections on port 25?
First check the message in the queue and the error log (/var/log/mail.err) Then in order to force deletion, you can do (even though it's in case of it's really stuck )