Wow ..... lots to take in! Thank you for your messages guys - I really appreciate your help! I'm not going to pretend that I understand even 10% of it but I'll do my best to get involved! :S I am going to admit right now that I am a bit of a PHP beginner and whilst I am getting better at understanding - I often do not! I have been learning Javascript and Xcode recently and have always meanrt to get onto PHP straight after .....
I will go back to:
RTFM on mail and you should get a better idea of what that function should be returning. This documentation says that function returns TRUE on success and FALSE on failure which makes me think you have made a mistake in copying NogDog's code because your code is returning NULL. Did you bother entering the first line $result = mail(blah blah blah) ?
All I can show you is what I did with the code that NogDog kindly provided and let you guys see what I did wrong ....... it is probably something laughable but I guess you don't learn without trying!
Right ..... Basically I took the code NogDog gave me and entered it into my FormToEmail code like so: (In RED)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<?php
function treat_submission()
{
$user = $_POST['first'];
$email = $_POST['email'];
$last = $_POST['last'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$my_email = "myemail@mydomain.com";
// MESSAGE TO ADMIN:
$headers = "To: ".$my_email. "\r\n";
$headers .= "From: ".$email. "\r\n";
$subject = "Form submitted via my website";
$msg = "".$user." ".$last." has submitted a form via the my website\r\n\r\n";
$msg.= "Email - ".$email."\r\n\r\n";
$msg.= "Phone - ".$phone."\r\n\r\n";
$msg.= "Comments - ".$comments."\r\n\r\n";
mail($my_email, $subject, $msg, $headers);
// MESSAGE TO VISITOR:
$headers = "To: ".$email. "\r\n";
$headers .= "From: ".$my_email. "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$subject = "Thank you for your interest in my website.";
$msg = "
<html>
<head>
<title>Thank You! </title>
</head>
<body>
<p>This is an automated response from me.
<br><br>
Your details have been forwarded to me blah blah blah.
<br><br>
We plan to be back to you quickly, but certainly within 24 hours during normal circumstances.
<br><br>
Kind Regards,
<br><br>
Me
</p>
</body>
</html>
";
mail($email,$subject,$msg,$headers);
}
?>
</head>
<body>
<?php
if (isset($_POST['submit']))
echo (treat_submission($_POST));
else
echo ("<p align=\"center\">The form has not been received.</p>");
[COLOR="Red"]$result = mail($email,$subject,$msg,$headers);
echo "<pre>DEBUG: mail() result:\n";
var_dump($result);
echo "</pre>";
[/COLOR]
?>
<div>
<center>
<p><b>Thank you <?php print stripslashes($_REQUEST['first']); ?></b>
<br>
</p>
<p>Your request has been submitted to me.</p>
<p>We will respond as soon as possible. </p>
<p><a href="http://www.mywebsite.com">Click here to return to our home page</a></p>
<p> </p>
</center>
</div>
</body>
</html>
Please do your best not to laugh at me if I have done something truly stupid!
Just a quick other question ... can any one begin to explain how a piece of code like this can suddenly fail on a variety of servers and any email address without being touched?!
Thanks again guys 🙂