Thinkphp中使用PHPmailer发送邮件
在ThinkPHP\Extend\Vendor\目录下放入PHPMailer文件夹,里面包含以下文件
重置密码发送邮件
public function recover(){
if($this->isPost()){
$mail=trim($_POST['mail']);
$pattern='1234567890abcdefghijklmnopqrstuvwxyz';
for($i=;$i<;$i++)
{
$key .= $pattern[mt_rand(,)];
}
$flag = M('m_auth_users') -> where(array(mail=>$mail))->setField('code',md5($key));
if($flag){
$url="http://***/index.php/Public/reset/code/".md5($key);
$body='您好:<br>请点击此链接 <a href='.$url.' >'.$url.'</a> 进行重置密码!';
Vendor('PHPMailer.PHPMailerAutoload');
sendmail('重置密码',$mail,$body);//发送邮件
$this->success('已向该邮箱发送重置密码邮件',U("Public/login"));
}else{
$this->error('该邮箱不存在');
}
}else{
$this->display();
}
}
发送邮件函数
function sendmail($subject,$address,$body){ $mail = new PHPMailer;
$mail ->CharSet='utf-8';
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = '邮件服务器地址'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '用户名'; // SMTP username
$mail->Password = '密码'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = '发件人';
$mail->FromName = '显示名称';
$mail->addAddress($address); // Add a recipient
$mail->WordWrap = ; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject =$subject;
//ip是否ping通邮件正文
$mail->Body = $body;
$mail->send();
/*
* if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';*/
}
Thinkphp中使用PHPmailer发送邮件的更多相关文章
- ThinkPHP 中使用 PHPMailer 发送邮件 支持163和QQ邮箱等
[摘要]ThinkPHP是一个开源的PHP框架, 是为了简化企业级应用开发和敏捷WEB应用开发而诞生的.本文介绍ThinkPHP 中使用 PHPMailer 发送邮件. PHP是自带可以发送邮件的Ma ...
- 在Thinkphp3.2 中使用PHPMailer 发送邮件
phpmailer发送邮件是php开发者首选的一个邮件发送插件了,下面我来介绍怎么集成phpmailer到thinkphp框架了,有需要了解的朋友可参考. phpmailer发送邮件功能很强大,今天真 ...
- ThinkPHP中使用PHPMailer邮件类
第一步.添加PHPMailer类库将下载后的文件解压,将PHPMail目录移动至ThinkPHP目录中的Vendor内.(请确保class.phpmailer.php文件就在ThinkPHP\Vend ...
- TP3.2 中使用 PHPMailer 发送邮件
第一步.添加PHPMailer类库 http://pan.baidu.com/s/1o7Zc7V0 第二步.添加发送邮件函数 在common目录中的公共函数文件加入函数 <?php /***** ...
- 在Yii Framework中利用PHPMailer发送邮件(2011-06-02 14:06:23)
转载▼ 标签: it 分类: 技术共享 官方扩展链接:http://www.yiiframework.com/extension/mailer/这个扩展配置十分方便,如果有问题的话,可以打开Debug ...
- thinkphp中怎么使用phpmailer发送邮件
phpmailer发送邮件是php开发者首选的一个邮件发送插件了,下面我来介绍怎么集成phpmailer到thinkphp框架了,有需要了解的朋友可参考. phpmailer发送邮件功能很强大,今天真 ...
- 将PHPMailer整合到ThinkPHP 3.2 中实现SMTP发送邮件
本内容转载出处:http://my.oschina.net/BearCatYN/blog/299192 并对以下内容做了一处说明. ThinkPHP没有邮件发送的功能,于是,我就想了想,就将PHPMa ...
- thinkphp使用PHPMailer发送邮件
第一步:准备PHPMailer 使用PHPMailer发送邮件,首先下载个PHPMailer 将下载的PHPMailer放到ThinkPHP文件夹里面的ThinkPHPExtendVendor 第二步 ...
- thinkphp5中使用phpmailer实现发送邮件功能(转载)
一.开启SMTP服务(使用php发送邮件需要用到SMTP服务,这里以163邮箱的SMTP服务为例). 1.登录163邮箱,在首页上找到“设置”. 2.选择开启的服务,一般都全选,POP3/SMTP/I ...
随机推荐
- MFC线程获取主窗口句柄
CWnd* h_q = AfxGetApp()->GetMainWnd(); //获取主窗口的句柄
- python 2 encode and decode
https://docs.python.org/2/howto/unicode.html a Unicode string is a sequence of code points, which ar ...
- python嵌套列表
从excel读取一行信息添加到一个临时列表,最后将所有行的列表添加到一个大列表. 源码: import xlrd,reclass Info(): def read_info(self): data = ...
- js 鼠标拖拽元素移动
<!DOCTYPE html><html> <head> <title> </title> <style media="sc ...
- 新增feeds模块
很简单,参考<产品差异化定制> 1.在fees/luci/model下面新增文件夹,必须的有:Makefile 和 luasrc/controller/admin/xxx.lua 2.执行 ...
- Go:map
一.map的创建方式 func main() { // map创建方式1 // 声明后再make var stu1 map[int]string stu1 = make(map[int]string, ...
- PHP:获取用户IP
文章来源:http://www.cnblogs.com/hello-tl/p/7685263.html //获取用户ip(外网ip 服务器上可以获取用户外网Ip 本机ip地址只能获取127.0.0.1 ...
- intellij idea 忽略文件不提交
文件已经纳入版本管理 如果文件已经纳入版本了,应该采用此方法 此方法主要应对文件已经纳入版本管理,但不想再提交,比如,不小心提交的eclipse.intellij的文件,以后不想再提交了,这种就通过v ...
- HDU-1022Train Problem I,简单栈模拟;
Train Problem I ...
- fzu 2113 数位dp
#include<stdio.h> #include<string.h> #define N 20 #define ll __int64 ll dp[N][N];//最多记忆4 ...