名站网址导航为大驾家提供DedeCMS站点程序站点教程相关的知识,比如织梦程序安装教程,织梦程序系统故障等教程。
织梦程序的邮件发送只能用系统MAIL系统数据库函数或者SMTP, 如果服务器是linux基本可不用配置任何SMTP信息。但是如果是windows机器,就必须配置SMTP。
咱们配置SMTP会出现意外,比如用QQ邮箱。
QQ邮箱:
1. 企业邮箱明显比QQ普通邮箱好用,不容易进入垃圾箱
2. QQ邮箱必须配置启用SMTP
在织梦程序DEDECMS关键系统数据库函数部分
require_once(dirname(__FILE__).'/../include/common.inc.php'); //在dedecms网站程序内必须引用 //邮件发送系统数据库函数 function sendmail($email, $mailtitle, $mailbody) { global $cfg_sendmail_bysmtp, $cfg_smtp_server, $cfg_smtp_port, $cfg_smtp_usermail, $cfg_smtp_user, $cfg_smtp_password, $cfg_adminemail,$cfg_webname; if($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_server)) { $mailtype = 'hTML'; 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; if(!$smtp->smtp_sockopen($cfg_smtp_server)){ ShowMsg('邮件发送失败,请联系管理员','-1'); exit(); } $smtp->sendmail($email,$cfg_webname,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype); }else{ @mail($email, $mailtitle, $mailbody, $headers); } } |
在相应页面做以下相关具体代码如下
if(!$_POST) exit; $address = admin@www.mzdh.net.com'; $name = $_POST['name']; $mailto = $_POST['email']; $mailtitle = $_POST['subject']; $mailbody = $_POST['message']; $sendtime = time(); if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); } $msg = "You have been contacted by $name with regards to $mailtitle.\r\n\n"; $msg .= "$mailbody\r\n\n"; $msg .= "You can contact $name via email, $mailto.\r\n\n"; $msg .= "-------------------------------------------------------------------------------------------\r\n"; if(@sendmail($address, $mailtitle, $msg, "From: $mailto\r\nReturn-Path: $mailto\r\n")) { echo "<p class='ajax_success'>Thanks for Contact Us.</p>"; } else { echo "<p class='ajax_failure'>邮件发送成功</p>"; } ?> |
再去包含个hTML页,就可以让用户通过邮件留言了
关于DedeCMS站点程序站点教程相关的知识,就说到这里了希望能帮助朋友们。织梦程序首页具体调用随机文章刷新就更新相关具体操作方法