CI php发送邮件

/**
*编码为utf-8
*
*/

<?php
class Sendmail extends Controller {
function Sendmail(){
   parent::Controller();
}

function mail()
{
$config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'smtp.qq.com',//服务器
      'smtp_port' => '25',
      'smtp_user' => '68155123@qq.com',//from
      'smtp_pass' => 'houryh3035',//password
      'mailtype' => 'html',//邮件类型
      'charset' => 'utf-8'//编码
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$from_name = "华领网络";//发件人名称
$email_subject = "GPS上客户登记:";//标题
$email_body = "士大夫论文242sdfl;sfl";//内容

//解决中文乱码问题
$from_name = iconv('GB2312','UTF-8',$from_name);//编码转换,把gb2312转换成utf-8
$email_subject = iconv('GB2312','UTF-8',$email_subject);
$email_body = iconv('GB2312','UTF-8',$email_body);


$this->email->from('68155123@qq.com', $from_name);
$this->email->to('281904975@qq.com');//to

$this->email->subject($email_subject);
$this->email->message($email_body);

if (!$this->email->send())
{
      show_error($this->email->print_debugger());
      return false;
}
else
{
      return true;
}
}
}
?>


本文来自:http://hi.baidu.com/ssfnadn/blog/item/d25d5fc488d4f0af8226acb9.html

另外:

如果icnov 不能使用参考:

http://www.jb51.net/article/14530.htm

http://apps.hi.baidu.com/share/detail/1797448


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值