icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » PHP mail() failing to send, sometimes?

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old May 27th, 2008, 12:41 AM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
PHP mail() failing to send, sometimes?

Hello Everyone,

Trying to write up a process to send a welcome mail to new users, but it seems the mail does not work for 'beyond server' addresses. Meaning if I enter a domain I control, on the same server as the mail() page, I get the mail. I send it to an outside domain/server(yahoo.com, or live.com, etc), no message recieved. It's like the mail can't leave the server.

Anyone else seeing this, or know how to tweak it to work?

thx,

tom
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 4:21 AM   #2 (permalink)
Registered User
Comfy Contributor
 
nathon's Avatar
 
Joined in Sep 2007
Lives in ~root
111 posts
Gave thanks: 1
Thanked 12 times
First, confirm that php mail is working by using the most basic test script possible and nothing else on the page.

PHP Mail

If that goes through then we know it is your coding or a conflict somewhere within.

If it doesn't then you need to do a ticket so the admins can go through mail logs to see what is going on, if it is leaving the server, or if php needs a recompile(99% of the time it isn't the case.

Just be sure you give them all the info like the URL to duplicate the problem, email you are sending to, etc.
__________________
I'm proud to say I never have and never will use vista
nathon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 8:57 AM   #3 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
I used one even simplier:

mail('someoneAnotherDomain.com', 'the subject', 'the message', null,'NoReplyxyz.com');

Tried this morning, no joy. Like I said, I can send to email addresses that exist on the server, but if they get forwarded, or send directly out, they die.

Anyone else?

thx,
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 10:42 AM   #4 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
P.S. Webbased email apps(squirrel mail, etc.) work. They do send email to outside domains.

thx,
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 10:43 AM   #5 (permalink)
Surpass Fan
Excelling Contributor
 
cowboy's Avatar
 
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
934 posts
Gave thanks: 2
Thanked 94 times
Quote:
Originally Posted by TommyD View Post
I used one even simplier:

mail('someoneAnotherDomain.com', 'the subject', 'the message', null,'NoReplyxyz.com');

Tried this morning, no joy. Like I said, I can send to email addresses that exist on the server, but if they get forwarded, or send directly out, they die.

Anyone else?

thx,
You are most likely being blocked by spam detectors. You at least have to add a "From" header. Check the php.net manual , http://www.php.net/quickref.php, for details.
__________________
Where would you be if you were at the highest court in the land (US)?
cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 10:50 AM   #6 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
Code:
<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

I tried this version(modified, with my information). Nothing.

tom

Last edited by TommyD; May 27th, 2008 at 10:51 AM.
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 8:26 PM   #7 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
I have a reply to a ticket I submitted, I have no 'sender'?

Can someone clarify this? This is my latest test example:

Code:
$to = 'outsideemailaccount@anotherdomain.com';
$from = 'webmaster@example.com';
$subject = 'hello';

$headers = 'From: webmaster@example.com' . "\r\n".
'Reply-To: webmaster@example.com'. "\r\n".
'Return-Path: webmaster@example.com' . "\r\n".
'X-Mailer: PHP/' . phpversion();
$message = "test123";

$rs = mail($to, $subject, $message, $headers, "-f ".$from);
thank you,

tom
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 27th, 2008, 10:22 PM   #8 (permalink)
Registered User
Fresh Surpasser
 
Joined in Mar 2006
9 posts
Gave thanks: 0
Thanked 0 times
All fixed, there was some server setting?

But happy now.

tom
TommyD is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On