有两种方法,我们来分别介绍一下,
网站建设时, 用dede自定义表单和留言后,想把留言和自定义表单内容发送到指定邮箱,
我们先来看一种简单的方法,直接用代码就可以了
1、 直接用代码的方法
打开plus下面的diy.php文件:
83行:$query = "INSERT INTO `{$diy->table}` (`id`, `ifcheck` $addvar) VALUES (NULL, 0 $addvalue); ";后面开始加入代码:
$mailtitle = $name."提交表单通知";
$mailbody = "称呼:{$name}\r\n邮箱:{$email}\r\n内容:{$message}";
$headers = $cfg_adminemail;
$mailtype = 'TXT';
require_once(DEDEINC.'/mail.class.php');
$smtp = new smtp($cfg_smtp_server,$cfg_smtp_port,true,$cfg_smtp_usermail,$cfg_smtp_password);
$smtp->debug = false;
$smtp->sendmail($cfg_smtp_usermail,$cfg_webname ,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);
$name $email $message 三个变量都是提交的字段,你提交的字段名称前面加$符号就行,这个根据你的需要来改。然后保存。
网站后台添加好发布邮箱的参数,这个教程不懂得话搜索下怎么设置,成功的话提交表单之后就会发送邮件到你的邮箱的,亲自测试过可以,其他网站建设的方法有点繁琐,类似第二种方法,我们来看一下。
2、这种方法网上一搜索很多,我们没有亲自试验过
打开/plus/diy.php 文件
找到如下代码:
PHP代码
-
require_once DEDEINC.'/diyform.cls.php';
-
$diy = new diyform($diyid);
在下面添加发送邮件代码,发送邮件代码见这里(一定要先看这里) PHPMailer 详细介绍及使用方法 发送邮件
PHPmailer 发送邮件设置指定发件人邮箱
以下是DEDE织梦实现代码,本人在dede5.7 sp1下测试成功
PHP代码
-
.....
-
require_once DEDEINC.'/diyform.cls.php';
-
$diy = new diyform($diyid);
-
-
require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录
-
$mail = new PHPMailer(); //建立邮件发送类
-
$address ="javlee@qq.com";
-
$mail->IsSMTP(); // 使用SMTP方式发送
-
$mail->Host = "smtp.163.com"; // 您的企业邮局域名
-
$mail->SMTPAuth = true; // 启用SMTP验证功能
-
$mail->Username = "legeorwa@163.com"; // 邮局用户名(请填写完整的email地址)
-
$mail->Password = "Arkbkwgkwg240."; // 邮局密码
-
$mail->Port=25;
-
$mail->From = "legeorwa@163.com"; //邮件发送email地址
-
$mail->FromName = $fullname;
-
$mail->AddAddress("$address", "Tibet");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")
-
if($action == 'post') {
if($do == 2) {
-
$mail->Subject = $trip; //邮件标题
-
$mail->Body = "Interested trip: $trip<br /> Full Name: $fullname<br /> E-mail: $email<br /> Contact Number: $contact<br /> Nationality: $nationality<br /> Number of Adult travelers: $travelers<br /> Number of children under 12: $children<br /> Approximate Entry Date: $entrydate<br /> Last city before entering Tibet: $city<br /> Hotel Class: $hotelclass<br /> Transportation preference: $preference<br /> Needed flight & train tickets from us: $flight<br /> What type of experience you are looking for?<br />$looking<br /><br /> Where would you like to visit?<br />$visit<br /><br /> What other information should we know?<br />$should<br /><br /> How did you know about us?<br />$about"; //邮件内容
-
$mail->AltBody = "This is the mail sent from tibetjiontour (Tailormake a tour)"; //附加信息,可以省略
-
-
if(!$mail->Send())
-
{
-
//echo "Fail to send. <p>";
-
//echo "Cause of the error: " . $mail->ErrorInfo;
-
//exit;
-
}
-
-
//echo "邮件发送成功";
-
}
-
}
-
-
/*----------------------------
-
function Post(){ }
-
---------------------------*/
-
在网站建设中,留言发邮件,和自定义表单提交后发送到邮箱,的方法你学会了吗??
There are two methods, we were introduced to it, construction sites, use dede custom forms and message after trying to leave a message, and custom form content is sent to the specified mailbox,
Let's look at a simple way, the code can be used directly