织梦的邮件发送只能用系统MAIL函数或者SMTP, 如果服务器是linux基本可不用配置任何SMTP信息。但是如果是windows机器,就必须配置SMTP。
配置SMTP会出现意外,比如用QQ邮箱。
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@liuzhongwei.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 "Thanks for Contact Us.
";}else{echo "邮件发送成功
";}?>
再去包含个HTML页,就可以让用户通过邮件留言了