phpmailer 使用
本帖最后由 dogwin 于 2014-6-30 22:50 编辑最近发现个好用的发邮件类-phpmailer分享给小伙伴们:
CI 建 librarise/Phpmail.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class CI_Phpmail{
function__construct(){
require_once(dirname(__FILE__)."/phpmailer/class.phpmailer.php");
}
function send_email($to,$from,$subject,$body,$from_name) {
global $error;
$mail = new PHPMailer();// create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0;// debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;// authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->FromName = $from_name;
$mail->Subject = $subject;
//$mail->Body = $body;
$mail->CharSet="utf-8";
$mail->Encoding = "base64";
$mail->AltBody = '';
$mail->WordWrap = 80;
$mail->MsgHTML($body);
$mail->IsHTML(true);
$mail->AddAddress($to);
return $mail->Send();
/*
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}*/
}
function test(){
echo "hello";
}
}
解压附件 放到 libraries 里
有问题叫我QQ:930988818
补充
librarise/Phpmail.php
librarise/Phpmailer
在controller 引
$this->load->library('phpmail');
$this->phpmail->send_email($to,$from,$subject,$body,$from_name);
感谢提供,引用的时候如何操作呢 okwindows 发表于 2014-6-30 18:37
感谢提供,引用的时候如何操作呢
librarise/Phpmail.php
librarise/Phpmailer
在controller 引
$this->load->library('phpmail');
$this->phpmail->send_email($to,$from,$subject,$body,$from_name);
感谢,顺利发出! okwindows 发表于 2014-6-30 23:28
感谢,顺利发出!
{:soso_e113:}
页:
[1]