Mail returns false

前端 未结 7 1256
太阳男子
太阳男子 2020-11-30 13:43

I\'m currently using a custom made library at my job. Until just rencently the library was working perfectly. It apparently return false since about today.

The libra

相关标签:
7条回答
  • 2020-11-30 14:10

    A good place to start is to check the error log.

    For apache and Ubuntu (for example), the error log is located under /var/log/apache2/error.log.

    This can give you a clue about what exactly is failing.

    0 讨论(0)
  • 2020-11-30 14:15

    Try setting the

    ini_set('sendmail_from', $from);
    

    If you could show us the code it would be easier to see what is going wrong.

    0 讨论(0)
  • 2020-11-30 14:19

    I had similar problem , mail function always returns false even if the email is received successfully.

    I found in php configuration file php.ini, I had set up

    ; For Win32 only.
    ;sendmail_from = me@example.com
    
    ; For Unix only.
    sendmail_path = "/usr/sbin/sendmail -t -i -f "care@mydomain.com"
    

    I have changed it to below

    ; For Win32 only.
    ;sendmail_from = me@example.com
    
    ; For Unix only.
    sendmail_path = /usr/sbin/sendmail -t -i -f care@mydomain.com
    

    As per this sendmail_from is for win32 , so in *unix OS we need to set the value as shown in sendmail_path variable.

    Regards Minesh

    0 讨论(0)
  • 2020-11-30 14:20

    It's possible that the address you are trying to send it to, the server that handles it is rejecting the mail.

    There are too many variables involved to say for sure.

    0 讨论(0)
  • 2020-11-30 14:28

    If the class is only a wrapper around the function mail, I would try printing to a file the parameters used when calling the mail function

    0 讨论(0)
  • 2020-11-30 14:28

    I just had the same problem. After a php upgrade, the mail function always returns false.

    I used this little snippet to check it out:

    <?php
    error_reporting(E_ALL|E_STRICT);
    ini_set('display_errors', 1);
    echo 'I am : ' . `whoami`;
    $result = mail('myaddress@mydomain.com','Testing 1 2 3','This is a test.');
    echo '<hr>Result was: ' . ( $result === FALSE ? 'FALSE' : 'TRUE') . $result;
    echo '<hr>';
    echo phpinfo();
    

    The solution was setting a value in my php.ini for 'sendmail_from' and 'sendmail_path'. The correct values in my case were:

    sendmail_from = "no-reply@mydomain.net"
    sendmail_path = "/usr/sbin/sendmail -t -i"
    

    (I'm using CentOS 5.3 w/ Zend Server CE.)

    You could use ini_set() to set the value of 'sendmail_from', but the 'sendmail_path' var must be setup in your php.ini or http.conf.

    • http://us3.php.net/manual/en/configuration.changes.modes.php
    • http://us3.php.net/manual/en/ini.list.php
    0 讨论(0)
提交回复
热议问题