php mail() very slow on centos 5.2 with postfix

Discussion in 'Server Operation' started by marm26, Jan 24, 2009.

  1. marm26

    marm26 New Member

    I am running a centos 5.2 server with postfix and php 5 installed.

    I am having problems with php mail(). Mails are sent but it takes about a minute for the page with the mail() function in it to load.

    The mails are very short and text only. I had the same script on a different server before (shared hosting) were things just worked perfectly and very fast. I suspect that there is a problem with my server settings. Any ideas???
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Any errors in Apache's error log (or the web site's error log)?
     
  3. marm26

    marm26 New Member

    No nothing in of any interest in apache or web error log.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    And in the mail log?
     
  5. marm26

    marm26 New Member

    ok here is the mail log. Not sure if this helps.

     
  6. falko

    falko Super Moderator Howtoforge Staff

    Can you post an excerpt where you try to send a mail with the PHP mail() function? I don't see anything like that in the excerpt you posted.
     
  7. marm26

    marm26 New Member

    I have send several mails with the php mail function that day. If there isnt anything in the mail error log that means it didnt throw an error. I mean the mail also got send. Just the script sending the mail is taking a minute or so to send out the mail.
     
  8. marm26

    marm26 New Member

    This is so strange. When i send out one mail message and i didnt send one in a while the script is running forever. But once i send this first mail message, the messages i send out right afterwards are sent in no time. Could it be that my mailing server has to be awakened from his winter sleep first before it starts sending mails. After i stop sending mails it seems to go back to sleep again within a few minutes. This is really not very satisfying. Is there anything i can do about that? what is causing this?
     
  9. falko

    falko Super Moderator Howtoforge Staff

    You could try to install a PHP opcode cacher like eAccelerator, Xcache, or APC and see if the behaviour changes.
     
  10. marm26

    marm26 New Member

    I thought I just let you know that I solved the issue. It was the sendmail path in php ini that caused the script to go incredibly slow.

    i changed it to:
    sendmail_path = /usr/lib/sendmail.postfix -t -i

    No the mails fire real fast. However I am having another problem now. In my maillog file I frequently see messages like this:

    Feb 1 19:44:29 server1 postfix/smtp[4591]: 88B9F14A81EE: to=<[email protected]>, relay=none, delay=20, delays=0.02/0.01/20/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)

    Same thing happens with yahoo or hotmail. It doesnt happen with every mail but quite often. Any ideas on this one?
     
  11. falko

    falko Super Moderator Howtoforge Staff

    What's in your resolv.conf?
     
  12. marm26

    marm26 New Member

    My resolv.conf looks like this:
    Code:
    # generated by NetworkManager, do not edit!
    
    ; Use a local caching nameserver controlled by NetworkManager
    
    
    nameserver 127.0.0.1
    
    I tried adding
    nameserver IPofMyServer.here
    nameserver IPofMYWebSite.here

    but the changes were lost when I rebooted the server. How can I make changes to this file without having to redo them each time the server reboots. Would the abouve be sufficient or is there anything else i should add?
     
  13. falko

    falko Super Moderator Howtoforge Staff

    Try
    Code:
    nameserver 145.253.2.75
    nameserver 213.191.92.86
    first to see if it works then.
     
  14. marm26

    marm26 New Member

    I added

    nameserver domainIP
    nameserver serverIP

    already.

    I didn't see the error message come up oin maillog anymore but I keep monitoring for a while.

    Still I guess if I reboot the server those changes will be lost again.

    Is there a way to make those changes permanent?
     
  15. falko

    falko Super Moderator Howtoforge Staff

    Run
    Code:
    system-config-network
    and fill in the DNS servers there.
     

Share This Page