发布日期:2016.09.01 08:13浏览量:3263作者:admin
网站开发中,我们经常会遇到cms可能不支持的邮箱,这种情况下我们就需要用到第三插件来进行替换自带程序功能!
1.首先把PHPMailer放入include,目录下
2.到member目录下的index_do.php大约在27-30左右找到
if($cfg_ml->fields['spacesta'] != -10)
{
ShowMsg('你的帐号不在邮件验证状态,本操作无效!', '-1');
exit();
}
在下面添加
require_once(DEDEINC.'/PHPMailer/class.phpmailer.php');
require_once(DEDEINC.'/PHPMailer/class.smtp.php');
//include("class.smtp.php");
//设置smtp参数
//获取一个外部文件的内容
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->SMTPSecure = "tls";
$mail->Host = $cfg_smtp_server;
$mail->Port = $cfg_smtp_port;
//填写你的gmail账号和密码
$mail->Username = $cfg_smtp_usermail;
$mail->Password = $cfg_smtp_password;
/ar_dump($cfg_smtp_usermail);
//设置发送方,最好不要伪造地址
$mail->From = $cfg_smtp_usermail;
$mail->FromName = $cfg_smtp_user;
然后在if($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_server))
{
//里面的覆盖掉
$mail->Subject = $mailtitle;
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($mailbody);
//设置回复地址
//$mail->AddReplyTo($email,$name);
//设置邮件接收方的邮箱和姓名
$mail->AddAddress($cfg_ml->fields['email'],$cfg_webname);
//使用HTML格式发送邮件
$mail->IsHTML(true);
//通过Send方法发送邮件
$mail->Send();
// $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_ml->fields['email'],$cfg_webname ,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);
}
以上替换完注册时的验证
3.找回密码邮件发送更改
在/member/inc/中找到inc_pwd_functions.php文件
if($cfg_sendmail_bysmtp == 'Y')
{
//替换其中的内容
require_once(DEDEINC.'/PHPMailer/class.phpmailer.php');
require_once(DEDEINC.'/PHPMailer/class.smtp.php');
//include("class.smtp.php");
//设置smtp参数
//获取一个外部文件的内容
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->SMTPSecure = "tls";
$mail->Host = $cfg_smtp_server;
$mail->Port = $cfg_smtp_port;
//填写你的gmail账号和密码
$mail->Username = $cfg_smtp_usermail;
$mail->Password = $cfg_smtp_password;
/ar_dump($cfg_smtp_usermail);
//设置发送方,最好不要伪造地址
$mail->From = $cfg_smtp_usermail;
$mail->FromName = $cfg_smtp_user;
$mail->Subject = $mailtitle;
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($mailbody);
//设置回复地址
//$mail->AddReplyTo($email,$name);
//设置邮件接收方的邮箱和姓名
$mail->AddAddress($email,$cfg_webname);
//使用HTML格式发送邮件
$mail->IsHTML(true);
//通过Send方法发送邮件
//根据发送结果做相应处理
$mail->Send();
}
以上内容替换后,可以使用任意加密格式邮箱进行注册用户的邮件发送(dede内置邮件程序支持ssl加密与不加密,tls是不支持的)