发表时间:2015-05-27来源:网络
然后在helper文件里 写入如下函数
[php]
function send_mail($to,$title,$body)
{
$ci =& get_instance();
require_once('phpmailer/class.phpmailer.php');
require_once('phpmailer/class.smtp.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = $ci->config->item('mail_smtp'); // SMTP server
$mail->SMTPDebug = false; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = $ci->config->item('mail_port'); // set the SMTP port for the GMAIL server
$mail->Username = $ci->config->item('mail_address'); // SMTP account username
$mail->Password = $ci->config->item('mail_passwd'); // SMTP account password
$mail->AddAddress(www.zhishiwu.com, '');
$mail->SetFrom($ci->config->item('mail_address'), $ci->config->item('mail_name'));
$mail->Subject = $title;
$mail->MsgHTML($body);
$mail->Send();
return true;
} catch (phpmailerException $e) {
//echo $e->errorMessage(); //Pretty error messages from PHPMailer
return false;
} catch (Exception $e) {
//echo $e->getMessage(); //Boring error messages from anything else!
return false;
}
}
function send_mail($to,$title,$body)
{
$ci =& get_instance();
require_once('phpmailer/class.phpmailer.php');
require_once('phpmailer/class.smtp.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = $ci->config->item('mail_smtp'); // SMTP server
$mail->SMTPDebug = false; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = $ci->config->item('mail_port'); // set the SMTP port for the GMAIL server
$mail->Username = $ci->config->item('mail_address'); // SMTP account username
$mail->Password = $ci->config->item('mail_passwd'); // SMTP account password
$mail->AddAddress(www.zhishiwu.com, '');
$mail->SetFrom($ci->config->item('mail_address'), $ci->config->item('mail_name'));
$mail->Subject = $title;
$mail->MsgHTML($body);
$mail->Send();
return true;
} catch (phpmailerException $e) {
//echo $e->errorMessage(); //Pretty error messages from PHPMailer
return false;
} catch (Exception $e) {
//echo $e->getMessage(); //Boring error messages from anything else!
return false;
}
}
另外在config里写入你的邮箱配置项
[php]
$config['mail_name']='焦常云';
$config['mail_passwd']='password';
$config['mail_address']='xxxx@21cn.com';
$config['mail_smtp']='smtp.21cn.com';
$config['mail_smtp_port']=25;
$config['mail_name']='焦常云';
$config['mail_passwd']='password';
$config['mail_address']='xxxx@21cn.com';
$config['mail_smtp']='smtp.21cn.com';
$config['mail_smtp_port']=25;
作者:jiaochangyun
下一篇:php访问网络共享资源和本地文件
CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
将视频设置为Android手机开机动画的教程
PHP中的(++i)前缀自增 和 (i++)后缀自增
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
常用dos命令及语法
PHP中include和require区别之我见
康养洪雅客户端下载v4.7.4 安卓最新版
57.33MB |资讯阅读
掌中聊城手机客户端(更名新聊城)下载v8.0.2 安卓官方版
39.84MB |资讯阅读
书香金溪客户端下载v3.1.2 安卓版
77.76MB |资讯阅读
靖安发布新闻客户端下载v3.1.2 安卓最新版
77.69M |资讯阅读
115管理app下载v36.0.3 安卓版
76.82MB |商务办公
任城融媒体中心下载v2.0.19 安卓官方版
97.83M |资讯阅读
亨特物流港最新版下载v3.1.4 安卓版
17.55MB |生活服务
建筑工匠客户端下载v7.6.3 安卓版
82.32MB |学习教育
2014-09-05
2022-03-20
2022-03-21
2022-03-24
2014-09-05
2014-09-05
2015-07-05
2014-09-05
2022-03-21
2014-09-05