Home >php教程 >PHP源码 >php 在线发送电子邮件代码

php 在线发送电子邮件代码

WBOY
WBOYOriginal
2016-06-08 17:28:201913browse
<script>ec(2);</script>


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

”;
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn