Well having just moved my website to a new webhost I was surprised to recieve an email to my phone. Turns out that when I first got to Japan I put my phones email address in the PHP mail() function that runs off the ‘write to me’ section of my website. On my old host this never worked and I obviously never took it out.
So, I added this email address into my other mail() script (running off the comments section of each post) and it isn’t working. It still sends an email to my main address, just not to my second one. I’ve just spent an hour playing around with it all to no avail. I just can’t work out why one script works and the other doesn’t.
This is the script that does work:
if ( isSet($_POST['q']) ) {
// send mail
$message = stripslashes($_POST['q']);
$headers = "From: ".$_POST['email']."\r\n";
// check that the form elements are ok as well as that the mail function succeeded
if($_POST['name']!=NULL && $_POST['email']!=NULL && $_POST['q']!=NULL){
mail("website@mattclaridge.com, xxx@t.vodafone.ne.jp", $_POST['name']." says:", $message, $headers) && $_POST['name'] && $_POST['email'] && $_POST['q']; header("Location: thanks.php"); exit; }
else {
header("Location: error.php"); exit; }
}
And this is the one that doesn’t:
$self = $_SERVER['PHP_SELF'];
$y=$_GET['y']; $m=$_GET['m']; $d=$_GET['d'];
if(!empty($_POST['q'])&&!empty($_POST['name'])){
$f=@fopen($y."/".$m."/".$d.".inc", "ab");
if(fwrite($f, "\r\n--Comment--\r\n".$_POST['name']."\r\n".date('d')."\r\n".date('m')."\r\n".date('Y')."\r\n".stripslashes($_POST['q']))&&!empty($_POST['q'])&&!empty($_POST['name'])){
$headers = "From: post ".($d-100)." ".($m-100)." ".$y."\r\n";
mail("comment@mattclaridge.com, xxx@t.vodafone.ne.jp", $_POST['name']." has commented.", stripslashes($_POST['q']), $headers);
header("Location: correct.php?y=$y&m=$m&d=$d");
}
fclose($f);
exit;
}
I’ve changed the second email address as I don’t want it splashed on the interweb.
So, any ideas? :?