有兩種方法,我們來分別介紹一下,
網站建設時, 用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