Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-27-2009, 08:12 AM   #1
LQ Newbie
Registered: Nov 2009
Posts: 5

Rep: Reputation: 0
Question Problems with PHP mail on new linux server....


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 the script used to send the mail works for google/yahoo..the code we are using is the following:

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!
Old 11-27-2009, 10:07 AM   #2
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
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.
Old 11-30-2009, 02:52 AM   #3
LQ Newbie
Registered: Nov 2009
Posts: 5

Original Poster
Rep: Reputation: 0

Thank you! We will do that...hopefully it is something that simple!
Old 11-30-2009, 02:55 AM   #4
LQ Newbie
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
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.
Old 11-30-2009, 06:19 AM   #5
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,629

Rep: Reputation: Disabled
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php: different mail server from php.ini rayds Programming 0 09-14-2004 03:48 AM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM
Sending mail with PHP on linux machine through exchange on Windows server 2003 TVScoundrel Linux - Newbie 1 06-18-2004 01:22 PM
Sending mail with PHP on linux machine through exchange on Windows server 2003 TVScoundrel Linux - Networking 2 06-18-2004 12:02 PM
problems with the apache & Php server of mandrake linux 9.1 krotaz Linux - Networking 6 11-21-2003 08:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration