PDA

View Full Version : problems with php - wont send mail


Instetus
04-18-2003, 09:51 AM
hello. i read a similar post and a kind guy wrote the php script for ryu (im glad there are ppl who actually wanna do these kind of stuff)

anyway, i used his script, he claims it works, but as i place it online for my form, btw, the form and everything is his creation, so the variables and stuff are correct.

if anyone would be so kind to dl the file and check it out (the script or anything else involved) and tell me what's wrong.

note: it has to be on a live server to work.

thanx. here is the file:

freddycodes
04-18-2003, 05:29 PM
Did you try just ahrd-coding values in the php script and running it from the browser, to see if and what errors were happening?
I had to make <? a <?php to work on my server, but then again I have my PHP short tags turned off. Anyways this should help in hte debugging process.

Try

<?
//Ryu, change the following variables for your values
$email_name="martin";
$email_to_send_to="instetus@yahoo.com";
//------------------------------------------------------------------------------



//Convert the posted variables to standard form for ease of reading
//$email=$_POST['email'];
//$comment=$_POST['comment'];

$email="instetus@yahoo.com";
$comment="This is a test";

instetus@yahoo.com

//Check for values in the fields
if(!$email){
$return_string.="&error3=1";
}
if(!$comment){
$return_string.="&error4=1";
}


if($return_string){//there are errors so return without sending mail
$return_string.="&has_errors=1";
echo $return_string;
exit();
}

//No errors so lets send the mail

//Build the message to send
$message="
The following data has been entered into your form

email:\n\t$email\n\n
comments:\n\$comment
";

$headers .= "From: $email_name < $email_to_send_to >\n";
$headers .= "X-Sender: < $email_to_send_to>\n";
$headers .= "X-Mailer: yourdomain.com form\n"; // mailer
$headers .= "X-Priority: 3\n"; // Urgent message!
$headers .= "Reply-To: $email_name < $email_to_send_to>\n";

mail($email_to_send_to, "Form data", $message, $headers);
echo "success";
?>