- 积分
- 14
- 威望
-
- 金钱
-
- 注册时间
- 2016-2-20
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2017-3-27 12:58:25
|
显示全部楼层
邮件代码
以下是邮件发送处理代码:
- <!--?php
- if(isset($_POST['submitted'])) {
- if(trim($_POST['contactName']) === '') {
- $nameError = '请输入联系人';
- $hasError = true;
- } else {
- $name = trim($_POST['contactName']);
- }
- if(trim($_POST['subjectContent']) === '') {
- $subjectError = '请输入主题';
- $hasError = true;
- } else {
- $name = trim($_POST['subjectContent']);
- }
-
- if(trim($_POST['email']) === '') {
- $emailError = '请输入您的邮箱';
- $hasError = true;
- } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}[ DISCUZ_CODE_0 ]quot;, trim($_POST['email']))) {
- $emailError = '邮箱格式不正确';
- $hasError = true;
- } else {
- $email = trim($_POST['email']);
- }
-
- if(trim($_POST['comments']) === '') {
- $commentError = '请输入邮件内容';
- $hasError = true;
- } else {
- if(function_exists('stripslashes')) {
- $comments = stripslashes(trim($_POST['comments']));
- } else {
- $comments = trim($_POST['comments']);
- }
- }
-
- if(!isset($hasError)) {
- $emailTo = get_option('tz_email');
- if (!isset($emailTo) || ($emailTo == '') ){
- $emailTo = get_option('admin_email');
- }
- $subject = '网站邮件:'.$name;
- $body = "姓名: $name \n\n邮箱: $email \n\n内容: $comments";
- $headers = '来自:'.$name.' <'.$emailTo.'>' . "\r\n" . '回复:' . $email;
-
- mail($emailTo, $subject, $body, $headers);
- $emailSent = true;
- }
-
- } ?>
复制代码
下面是邮件主体内容表单提交代码:
- <?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?>
- <!--?php if($commentError != '') { ?-->
- <!--?=$commentError;?-->
- <!--?php } ?-->
复制代码
[ 本帖最后由 半岛小生 于 2017-3-27 13:00 编辑 ] |
|