I've been fiddling about with this script to get it to add the email post variable to a flatfile which works well (I need to grab all the entered email names for a newsletter... (there is a single field in a form for the user to fill in their email address)
however, I've been trying to have it send an email notice to the admin (me)@myaddress to notify me whenever anybody fills in the field -
and I've tried this but... any ideas on where I'm going wrong
//Modified this to my email address
$sendto='me@myaddress.com';
//Modified this for displaying the subject in the mail
$subject="Subscription Notice";
//Modified this for displaying the info in the mail
mail($sendto,$subject,$message,"From: <$email>");
however, I've been trying to have it send an email notice to the admin (me)@myaddress to notify me whenever anybody fills in the field -
and I've tried this but... any ideas on where I'm going wrong
//Modified this to my email address
$sendto='me@myaddress.com';
//Modified this for displaying the subject in the mail
$subject="Subscription Notice";
//Modified this for displaying the info in the mail
mail($sendto,$subject,$message,"From: <$email>");
Code:
<?php
//get email value from POST variable
$email = trim($_POST['email']);
//add a new line for Each email address
$email .="\n";
//initialize the variable
$fileName = "subscribe.txt";
//open files
if (is_writable($fileName)) {
if(!$fp = fopen($fileName,"a")){
echo "status=Can't open the file name $fileName";
exit;
}
if (fwrite($fp,$email) === FALSE) {
echo "status=Can't write to $fileName";
exit;
}
echo "status=ok";
fclose($fp);
} else {
echo "status=The file $fileName is not writable";
}
?>