织梦邮件函数做到独立页面的方法
织梦的邮件发送只能用系统MAIL函数或者SMTP, 如果服务器是linux基本可不用配置任何SMTP信息。但是如果是windows机器,就必须配置SMTP。
我们配置SMTP会出现意外,比如用QQ邮箱。
QQ邮箱:
1. 企业邮箱明显比QQ普通邮箱好用,不容易进入垃圾箱
2. QQ邮箱必须配置启用SMTP
3. SSL明显比不启用效率高
在织梦DEDECMS关键函数部分
require_once(dirname(__FILE__).’/https://www.adminbuy.cn/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@lol9.cn’;
$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.
”;
$msg .= “$mailbody
”;
$msg .= “You can contact $name via email, $mailto.
”;
$msg .= “——————————————————————————————-
”;
if(@sendmail($address, $mailtitle, $msg, “From: $mailto
Return-Path: $mailto
”))
{
echo “
Thanks for Contact Us.
“;
}
else
{
echo “
邮件发送成功
“;
}
?>
再去包含个HTML页,就可以让用户通过邮件留言了
☉本站提供的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
pbootcms模板网 » 织梦邮件函数做到独立页面的方法