LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problems with PHP mail on new linux server.... (https://www.linuxquestions.org/questions/linux-newbie-8/problems-with-php-mail-on-new-linux-server-771915/)

impelmedia 11-27-2009 08:12 AM

Problems with PHP mail on new linux server....
 
Hello!

I have been tearing my hair out all day over this one.... we are currently migrating from a windows web server to a linux box with apache and php 5... however my mail scripts within our websites are causing us big problems! I can send mail to googlemail and yahoo, but if i try to send it to a custom mail server (i.e. our business mailserver) or an email address currently located at our old web server nothing is coming through. I'm not getting any errors when i send the mail though - the response comes back as '1', as in success....well surely no emails coming through means this is a lie?!?!?! I have a feeling it is a server side problem....as the script used to send the mail works for google/yahoo..the code we are using is the following:

Code:

include "/usr/share/php/Mail.php";
     
        $date = date("D, d M Y H:i:s O");
     
        $returnPath = "email@address";

        $from = "email@address";
     
        $to = $_POST['email'];
     
        $subject = "Forgotten Password - New Login Details";
     
        $body = $message;
     
        $host = "localhost";
     
        $username = "username";
     
        $password = "password";
     
     
        $headers = array ('From' => $from,
     
          'To' => $to,
     
          'Subject' => $subject,
       
          'Date' => $date,
     
          'Return-path' => $returnPath);
     
        $smtp = Mail::factory('smtp',
     
          array ('host' => $host,
     
            'auth' => true,
     
            'username' => $username,
     
            'password' => $password));
     
     
     
        $mail = $smtp->send($to, $headers, $body);

Can anyone help?? Obviously we don't want our clients without their mail facilities for very long!

Thanks in advance!

Web31337 11-27-2009 10:07 AM

have they received mail before you moved?
if you can send it and google,yahoo can get it, perhaps you need to look onto your mail servers.

impelmedia 11-30-2009 02:52 AM

Thank you! We will do that...hopefully it is something that simple!

jippen 11-30-2009 02:55 AM

I do support for a spam filtering company for a living so, believe me, I've seen a lot of this sort of thing happening.

I recommend checking the logs on your mailserver, to see if it rejected the email. If you can't access the logs, or can't find them, run a packet capture, send a test email to yahoo, and one to the work server, and check what the differences are.

linuxlover.chaitanya 11-30-2009 06:19 AM

If its your server you could try using a PEAR library. I remember using this library some time ago for the same purpose. Do not have the code at hand but can surely give you a day later.


All times are GMT -5. The time now is 04:50 PM.