【www.gdgbn.com--浏览器】


Mail sender


Email


Subject


Message





该窗体包含必要的文本字段电子邮件,主题,消息和发送按钮。该生产线

告诉浏览器的PHP文件将处理的形式和使用什么方法发送data.When用户在填好表格,并点击发送按钮, mail.php文件被称为...


PHP Mail Sender

/* 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"];
/*Validation of subject and also mail */
if (!preg_match(”/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/”, $email)) {
  echo “

Invalid email address

”;
  echo “Back”;
} elseif ($subject == “”) {
  echo “

No subject

”;
  echo “Back”;
}
/* 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)) {
  echo “

Thank you for sending email

”;
} else {
  echo “

Can’t send email to $email

”;
}
?>

本文来源:http://www.gdgbn.com/bangongshuma/23541/