PHP Mail() Problem

here is what I’m using:
[php]
$subject = $sys[‘name’]." Validation Email Link";
$message = $subject."\r\n\r\n";
$message.= “Your Validation Email Link: \r\n”;
$message.= $sys[‘home’].“index.php?sess=”.$urow[‘sess’];
user_text($message,$subject,$urow[‘email’],$sys[‘email’]);
[/php]

to send to a php function called user_text
the variables are filled in according to what user email
is entered and the database fills in the $sys variables.

this is the code it is sent to:
[php]
function user_text($message,$subject,$useraddress,$address){
// Recipients
$mailTo = $useraddress;

// From
$mailFrom = $address;

// Reply address
$mailReplyTo = $address;

// Message subject and contents
$mailSubject = $subject;
$mailMessage = $message;

// Text message charset
$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)

// Create headres for mail() function
$headers  = "Content-type: text/plain; charset=$mailCharset\n";
$headers .= "From: ".$mailFrom."\n";
$headers .= "Reply-To: $mailReplyTo\n";
$headers .= "Return-Path: $mailReplyTo\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\n";


// Send mail
mail($mailTo, $mailSubject, $mailMessage, $headers);

}
[/php]

this php script works great if the $sys[‘home’] in the database
has a domain of something.com or something.net or even a
miss type of something.ne but when I decided to use my domain
of something.us email will not be sent. The .us for some reason
keeps the mail() from sending the email.

have any ideal??

So as long as its not your email address the script works? Do you have any confirmation to see if the email was sent?

Hello thank for your reply

I do not believe there is anything the script is doing wrong

I simplified the script a little more to explain the problem I’m having:
please have a look at this php script:

[php]
function user_text($message,$subject,$email,$semail)
{
// Recipients
$mailTo = $email;

// From
$mailFrom = $semail;
$mailFromName = "Surefire Traffic";

// Reply address
$mailReplyTo = $semail;

// Message subject and contents
$mailSubject = $subject;
$mailMessage = $message;
echo $message,"<br>";
// Text message charset
$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)

// Create headres for mail() function
$headers  = "Content-type: text/html; charset=$mailCharset\r\n";
$headers .= "From: $mailFromName <$mailFrom>\r\n";
$headers .= "Reply-To: $mailReplyTo\r\n";

// Send mail
mail($mailTo, $mailSubject, $mailMessage, $headers);
echo("<br>Finished sending email.");

}
$user = "[email protected]";
$sys = "[email protected]";
$subject = “Surefire Traffic Validation Email Link”;
$message = “Validation Email

”;
$message.= “Your Validation Email Link:
”;
$message.= “http://www.surefiretraffic.us/new_sft/index.php?sess=123456”;
echo user_text($message,$subject,$user,$sys);
[/php]

now with this script the way it is, it will not send mail. BUT the only reson
it will not send the mail is because of the (.us) where the line –
$message.= “http://www.surefiretraffic.us/new_sft/index.php?sess=123456”;

now if I change the (.us) to anything else SAY (.net) or (.com) or even (.abc) then
the mail will send.

the domain is inside the message though, shouldn’t have anything to do with the actual email. Any idea which one of the mail() is failing? the second script has two of them and the second is missing the headers - which would cause a server to think its spam and possibly reject it.

no the headers are there in the second one, you must of over looked them.

As one of the first few posts in this thread said, you might need confirmation saying it was sent. This will help quite a bit.

Mail() comes out true if it was sent, and, conveniently, false if it wasn’t sent.

You can do something like this

[php]$email = mail($recipient, $subject, $message);
if($email = true) {
echo “Email sent”;
}

else {
die('Error: ’ . mysql_error());
}[/php]

This checks if it was sent or not. If not sent, the error line will tell you where and what went wrong

this is what I get back:

Validation Email

Your Validation Email Link:
http://www.surefiretraffic.us/new_sft/index.php?sess=123456
Email sent
Finished sending email.

I’m thinking the only way I’m getting around this is to
change my domain name.

why change the domain, the email got sent out. If there was a problem sending it, you’d get a false. Wether you’re testing for false idk.

This is just the weirdest thing, right after doing the test to see that it was sent
and for no other reason I can think of it started working. That almost bothers me
more now then before because I have know ideal why it would just start working
again and is it going to continue working or just stop again without me knowing.

Chances are good that the email is getting sent to spam folder, then released. Hotmail does the samething with email it doesn’t recognize.

Sponsor our Newsletter | Privacy Policy | Terms of Service