ok i have a php mail problem. i created a flash ecard system that uses PHP to mail(www.beaniekids.com/ecards) and the problem is that the recipient email is never recived (although this exact same system works on my other host www.mitchellpage.com.au/ecards)
php is enabled on both servers. i thought it might be a mail problem so i set up this test page (www.beaniekids.com/ecards/test.php) and IT WORKS - email is recieved.
sorry for the lot of code but i have pasted both sets of code below. maybe someone can tell me why its not working on one server but is on another?
THIS CODE is used to mail the ecard notification to the recipient or TO email:
<?
$CreateEcard = date(U);
$filename = $CreateEcard.".txt";
$ToName = stripslashes($ToName);
$FromName = stripslashes($FromName);
$Greeting = stripslashes($Greeting);
$IntroMessage = stripslashes($IntroMessage);
$EndMessage = stripslashes($EndMessage);
$Today = (date ("l dS of F Y ( h:i:s A )",time()));
$Created="Ecard Created on $Today";
$EcardNum = $EcardSelect;
$EcardText = "ToName=$ToName&ToEmail=$ToEmail&FromName=$FromName&FromEmail=$FromEmail&Greeting=$Greeting&IntroMessage=$IntroMessage&Created=$Created";
$fp = fopen( "./dBText/$filename","w");
fwrite($fp, $EcardText, 10000);
fclose( $fp );
$ToSubject = "You have recieved a Flash Ecard from $FromName";
$Message = "$ToName,\nYou have recieved a Beanie Kids E-Card from $FromName. \nClick the following link to view your card:\n\n http://www.beaniekids.com/ecards/SelectCard.php?EcardText=$CreateEcard&ENum=$EcardNum\n\n-----------------------------------\nHere is the message that was sent:\n$ToName,\n$Greeting\n$IntroMessage\n\n-$FromName\n\n\n-----------------------------------";
###################
## This line actually sends the email - you should not have to change this.
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FromName." <".$FromEmail.">");
## This next line returns a success message to the Flash movie.
print "_root.status_txt=Success! Your E-Card Has Been Sent!";
?>
This code is used by mail.php (called from test.php) to send mail (this works):
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$headers = 'From: Matthew <matthew@example.com>' . "\r\n";
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message,$headers)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
Thanks In Advance Guys!