我们配置SMTP会出现意外,比如用QQ邮局。织梦58测试发现
QQ邮箱:
1. 企业邮箱明显比QQ普通邮箱好用,不容易进入垃圾箱
2. QQ邮箱必须配置启用SMTP
3. SSL明显比不启用效率高
在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@@dede58.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.rnn"; $msg .= "$mailbodyrnn"; $msg .= "You can contact $name via email, $mailto.rnn"; $msg .= "-------------------------------------------------------------------------------------------rn"; if(@sendmail($address, $mailtitle, $msg, "From: $mailtornReturn-Path: $mailtorn")) { echo "
Thanks for Contact Us.
"; } else { echo "邮件发送成功
"; } ?>再去包含个HTML页,就可以让用户通过邮件留言了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)