@AliceXT
2016-01-05T02:40:52.000000Z
字数 2228
阅读 409
分销系统
功能点 | 天数 | 完成日期 | 备注 |
---|---|---|---|
整理需要的数据资料 | 1 | 2015-9-2 | |
连接登录 | 1 | 2015-9-10 | |
配置信息设置 | 1 | 2015-9-10 | |
链接注册页面 | 1 | 2015-9-11 |
配置值框中填写的值
SMTP_PORT:465
SMTP_USER:8jing8jing8@163.com
SMTP_PASS:2010930609
FROM_EMAIL:8jing8jing8@163.com
FROM_NAME:芳芳庄园10000
SMTP_HOST:smtp.163.com
REPLY_EMAIL:8jing8jing8@163.com
REPLY_NAME:芳芳庄园10000
路径:/Addons/Shop/Controller/
函数:_initialize()
在$this->assign ( 'nav', $nav );
之前
增加代码:
/**
* @author AliceXT2015-9-10
**/
$res ['title'] = '网页配置';
$res ['url'] = addons_url ( 'Shop://Web/config' );
$res ['class'] = $controller == 'web' ? 'current' : '';
$nav [] = $res;
/* change end */
路径:\Application\Home\Common\
在文件的最后
增加代码:
/**
* 系统邮件发送函数
* @param string $to 接收邮件者邮箱
* @param string $name 接收邮件者名称
* @param string $subject 邮件主题
* @param string $body 邮件内容
* @param string $attachment 附件列表
* @return boolean
*/
function think_send_mail($to, $name, $subject = '', $body = '', $attachment = null){
$config = C('THINK_EMAIL');
vendor('phpmailer.class#phpmailer'); //从PHPMailer目录导class.phpmailer.php类文件
$mail = new PHPMailer(); //PHPMailer对象
$mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 0; // 关闭SMTP调试功能
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = 'ssl'; // 使用安全协议
$mail->Host = $config['SMTP_HOST']; // SMTP 服务器
$mail->Port = $config['SMTP_PORT']; // SMTP服务器的端口号
$mail->Username = $config['SMTP_USER']; // SMTP服务器用户名
$mail->Password = $config['SMTP_PASS']; // SMTP服务器密码
$mail->SetFrom($config['FROM_EMAIL'], $config['FROM_NAME']);
$replyEmail = $config['REPLY_EMAIL']?$config['REPLY_EMAIL']:$config['FROM_EMAIL'];
$replyName = $config['REPLY_NAME']?$config['REPLY_NAME']:$config['FROM_NAME'];
$mail->AddReplyTo($replyEmail, $replyName);
$mail->Subject = $subject;
$mail->AltBody = "为了查看该邮件,请切换到支持 HTML 的邮件客户端";
$mail->MsgHTML($body);
$mail->AddAddress($to, $name);
if(is_array($attachment)){ // 添加附件
foreach ($attachment as $file){
is_file($file) && $mail->AddAttachment($file);
}
}
return $mail->Send() ? true : $mail->ErrorInfo;
}