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 setup a server so that I can send email from PHP using the mail() function. I tried running a script that I know works but never got the email. Here is the log file:

Sep  1 13:58:27 server1 postfix/master[5318]: daemon started -- version 2.5.5, configuration /etc/postfix
Sep  1 13:59:21 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 13:59:21 server1 dovecot: Generating Diffie-Hellman parameters for the first time. This may take a while..
Sep  1 13:59:22 server1 dovecot: Killed with signal 15
Sep  1 13:59:22 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 13:59:22 server1 dovecot: Generating Diffie-Hellman parameters for the first time. This may take a while..
Sep  1 13:59:22 server1 dovecot: Killed with signal 15
Sep  1 13:59:22 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 13:59:22 server1 dovecot: Generating Diffie-Hellman parameters for the first time. This may take a while..
Sep  1 14:12:37 server1 postfix/master[5318]: terminating on signal 15
Sep  1 14:12:37 server1 postfix/master[5998]: daemon started -- version 2.5.5, configuration /etc/postfix
Sep  1 14:12:41 server1 dovecot: Killed with signal 15
Sep  1 14:12:41 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 14:21:16 server1 postfix/master[5998]: terminating on signal 15
Sep  1 14:21:18 server1 dovecot: Killed with signal 15
Sep  1 14:22:14 server1 postfix/master[2031]: daemon started -- version 2.5.5, configuration /etc/postfix
Sep  1 14:24:31 server1 postfix/master[2033]: daemon started -- version 2.5.5, configuration /etc/postfix
Sep  1 14:25:22 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 14:39:44 server1 postfix/master[2033]: terminating on signal 15
Sep  1 14:39:48 server1 dovecot: Killed with signal 15
Sep  1 14:40:43 server1 postfix/master[2033]: daemon started -- version 2.5.5, configuration /etc/postfix
Sep  1 14:40:44 server1 dovecot: Dovecot v1.0.15 starting up
Sep  1 14:43:28 server1 postfix/pickup[2042]: 5FAEE256327: uid=33 from=<www-data>
Sep  1 14:43:28 server1 postfix/cleanup[2214]: 5FAEE256327: message-id=<20090901184328.5FAEE256327@server1.dev.com>
Sep  1 14:43:28 server1 postfix/qmgr[2044]: 5FAEE256327: from=<www-data@server1.dev.com>, size=418, nrcpt=1 (queue active)
Sep  1 14:43:28 server1 postfix/smtp[2216]: connect to gmail-smtp-in.l.google.com[209.85.210.23]:25: No route to host
Sep  1 14:43:28 server1 postfix/smtp[2216]: connect to alt1.gmail-smtp-in.l.google.com[209.85.212.8]:25: No route to host
Sep  1 14:43:28 server1 postfix/smtp[2216]: connect to alt2.gmail-smtp-in.l.google.com[209.85.219.43]:25: No route to host
Sep  1 14:43:28 server1 postfix/smtp[2216]: connect to alt3.gmail-smtp-in.l.google.com[209.85.129.114]:25: No route to host
Sep  1 14:43:28 server1 postfix/smtp[2216]: connect to alt4.gmail-smtp-in.l.google.com[209.85.222.4]:25: No route to host
Sep  1 14:43:28 server1 postfix/smtp[2216]: 5FAEE256327: to=<blackarmadillo@gmail.com>, relay=none, delay=0.26, delays=0.11/0.04/0.11/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[209.85.222.4]:25: No route to host)

I'm guessing it has something to do with the "No route to host"... any ideas?

share|improve this question

4 Answers 4

You need to resolve the "No route to host" issue before you can get e-mail through. You can test it by running the following command from the server:

   telnet 209.85.222.4 25

It should look something like:

   guin:~$ telnet 209.85.222.4 25
   Trying 209.85.222.4...
   Connected to 209.85.222.4.
   Escape character is '^]'.
   220 mx.google.com ESMTP 4si19030170pzk.29
   quit
   221 2.0.0 closing connection 4si19030170pzk.29
   Connection closed by foreign host.
   zsh: exit 1     telnet 209.85.222.4 25
   guin:~$ 

Where I typed "quit" to exit. If you don't get the "220" line, your server has problems connecting to the remote mail server.

If that is the case, I'd guess it's either a routing problem (missing default route? Check "netstat -nr" output), or a firewalling issue (check "iptables-save | less" output).

Sean

share|improve this answer
    
I'm pretty new to this stuff so checking the output of those two didn't do me a whole lot. Here is the output of netstat -nr: Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 and when I ran iptables-save | less it was just a blanks screen... I never setup iptables so maybe that's my problem. Any guidance in what I should do would be greatly appreciated. Thanks. –  blcArmadillo Sep 2 '09 at 1:07
    
Arg... the netstat output formatting didn't exactly carry over as planned. Here is a screenshot to make things simpler: i27.photobucket.com/albums/c190/blcArmadillo/netstat.jpg –  blcArmadillo Sep 2 '09 at 1:09
    
Oh... and when I ran "telnet 209.85.222.4 25" I got "No route to host" –  blcArmadillo Sep 2 '09 at 1:11

FYI: Google Mail was down earlier today. You didn't specify if this was causing trouble with other hosts.

If it's still causing you trouble, then perhaps your network administrator is blocking outgoing port 25. Some ISPs do this to stop spam. You can contact your network administrator for details about that.

share|improve this answer

those ip's are reachable from your server; I guess you don't have connection to them, though your dns resolves mx for gmail

try telnetting to port 25 to at least one of those ip addresses

please check your routing and firewall rules

share|improve this answer

On your sever you can try this command : sendmail someaddress@email.com Subject: test CTRL +D

then cat /var/log/mail.info and check if you mail is sent. If you have any issue by sending an email from terminal then that won't work with php.

Tell us what the command gives you

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.