artech Posted March 15, 2010 Share Posted March 15, 2010 Okay, so I have a page that needs to email the site administrator. The message is hard coded, the recipient and headers are hard coded. Nothing from the user. The code is up on the client's server, working great. I get the email right away, every time. Ran the page a large number of times and never missed a message. So I change my email value to the email address of the administrator. No email. No errors. So I move the script onto my server and run it. He gets the email. I get the email. I am terribly frustrated and these guys are up against a deadline, which is adding to my stress. Anyone have an idea of what is going wrong? The script is as follows (strings and emails are sterilized). # here is the email script that is messing with me # thanks for taking a look! # ----------------------------------------------------# // send email notification to site administrator // start setting up the email $from= "[email protected]"; $to= "[email protected]"; $subject = "Email Notification"; // create the text for the message body $message = "string text for line 1\n"; $message .= "string text for line 2\n"; $message .= "string text for line 3\n\r"; $message .= "This email was generated on ".date('Y-m-d H:i:s'); // now start a while wrapper to make sure we try // sending the email until it succeeds while (!$mail) { $mail = mail($to, $subject, $message, "From: ".$from." <".$from.">\r\n" ."Reply-To: ".$from."\r\n" ."X-Mailer: PHP/" . phpversion()); } Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/ Share on other sites More sharing options...
harristweed Posted March 15, 2010 Share Posted March 15, 2010 If The script works on your server but not on their server, it must be a server issue. (The script works on my apache 2 / php5). Open a support ticket! Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026214 Share on other sites More sharing options...
artech Posted March 15, 2010 Author Share Posted March 15, 2010 I'll take the suggestion of opening a support ticket. At least on the surface, the server configurations are the same, but I know that 'on the surface' doesn't count for much with third party hosts. I updated the config files I have access to to match their server. Do you have any ideas of what kind of error could possibly be making their server succeed when sending the email to my address but fail when sending to either of the administrator's email addresses? Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026215 Share on other sites More sharing options...
harristweed Posted March 15, 2010 Share Posted March 15, 2010 Hi, No I don't know.... but I put the question to Google and got loads of stuff http://www.adrogen.com/blog/email-not-sending-to-same-domain/ Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026217 Share on other sites More sharing options...
PFMaBiSmAd Posted March 15, 2010 Share Posted March 15, 2010 For debugging purposes, turn on full php error reporting/display. Add the following two lines of code after the first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL); For each of the servers where you tried this, where are both the To: and From: email address hosted at relative to the sending mail server? About the only thing that putting the mail() function in a while(){} loop will accomplish is getting the web host upset at you and suspending your hosting account. If an error is occurring, that will just make an infinite loop connecting to the sending mail server and passing it the same values over and over until the php script times out. Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026232 Share on other sites More sharing options...
artech Posted March 15, 2010 Author Share Posted March 15, 2010 For debugging purposes, turn on full php error reporting/display. Add the following two lines of code after the first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL); No errors, even with full report/display turned on. For each of the servers where you tried this, where are both the To: and From: email address hosted at relative to the sending mail server? Client Server: MediaTemple My Server: GoDaddy My email # 1 Hosted at a University Same university that hosts Client email #1 Not hosted by the sending mail server My email #2 Hosted at my GoDaddy server Not hosted by the sending mail server Client email #1 Hosted at a University Same university that hosts My email #1 Not hosted by the sending mail server Client email #2 Hosted at client's MediaTemple server Is hosted by the sending mail server Outcome: I receive the email notification regardless of address and regardless of sending mail server. My client receives the email notification when the script is hosted on my server but does not receive the email notification when the script is hosted on their server. About the only thing that putting the mail() function in a while(){} loop will accomplish is getting the web host upset at you and suspending your hosting account. If an error is occurring, that will just make an infinite loop connecting to the sending mail server and passing it the same values over and over until the php script times out. Thanks for the tip! Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026240 Share on other sites More sharing options...
Deoctor Posted March 15, 2010 Share Posted March 15, 2010 check whether the port 25 is opened in the host from which ever u are not getting mail.. Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026247 Share on other sites More sharing options...
artech Posted March 15, 2010 Author Share Posted March 15, 2010 check whether the port 25 is opened in the host from which ever u are not getting mail.. documentation shows port as open Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026252 Share on other sites More sharing options...
Deoctor Posted March 15, 2010 Share Posted March 15, 2010 not with the documentation try this telnet <hostname or ip> 25 if this shows some results then port is opened.. or else if it gives some thing like this then the port is closed.. Connecting To <ip address>...Could not open connection to the host, on port 25: Connect failed Quote Link to comment https://forums.phpfreaks.com/topic/195277-i-cant-figure-out-what-is-wrong-with-this-mail-script/#findComment-1026253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.