PHP mail() timeout

后端 未结 5 1632
遇见更好的自我
遇见更好的自我 2021-02-13 23:17

First a few infos:

  • Debian Squeeze
  • PHP 5.3.3
  • PHP with mod_cgi
  • I absolutely HAVE to use mail() in this case. For all my other
相关标签:
5条回答
  • 2021-02-14 00:03

    I've been searching for this particular error and have found that it can be caused by a variety of things. I do not know what you have already tried to do to fix it, but here are some suggestions as to what might help:

    • Make sure to start with <?php and end with ?>
    • Make sure to chmod the file to 755
    • Try to include an output of some sort (eg. print "Mail sent.")

    There's also another question about this subject here on SO: PHP Mail Function Causes Error - The owner stated that a change of server with the same setup resulted in a working mail() function, which could indicate a problem with the host.

    0 讨论(0)
  • 2021-02-14 00:15

    Do you have a problem using:

    exec('php -r \"mail('rudolf@geardev.de', 'test', 'test');\"');
    
    0 讨论(0)
  • 2021-02-14 00:17

    Do not rely on mail() as it is unreliable and leads to issues just like these. I've used phpMailer for years quite happily.

    If you persist on mail() then check your settings in php.ini (explained at http://www.quackit.com/php/tutorial/php_mail_configuration.cfm). Note that usually CLI has a different php.ini than FastCGI.

    Some more common problems:

    • FastCGI doesn't have permissions to use sendmail

    • Memory limit with large attachments

    0 讨论(0)
  • 2021-02-14 00:19

    Is it possible that you have a firewall blocking outgoing SMTP connections? Are there other things on that server that can successfully send email?

    I would make this a comment, but am not allowed to yet.

    0 讨论(0)
  • 2021-02-14 00:24

    Most likely you use 2 different php.ini versions. one for cli and one for cgi. Debian have this setup i believe.

    • /etc/php5/cgi/php.ini
    • /etc/php5/cli/php.ini

    Make sure that your cli and cgi versions have the same email configuration and it will work.

    The mail configuration key is: [mail function]

    Another possibility is that your web user does't have access to execute sendmail.

    Also check spool permissions (updated)

    0 讨论(0)
提交回复
热议问题