<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MyEmail extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index( $param=array() )
{
$config = array(
'protocol' => 'smtp', // 'smtp_host' => 'smtp.qq.com',//服务器
'smtp_host' => 'smtpcom.263xmail.com',
'smtp_port' => '25',
'smtp_user' => 'xxxx.com',
'smtp_pass' => 'xxx',//password
'mailtype' => 'html',//邮件类型 '
'charset' => 'utf-8'//编码
);
$this->load->library('email', $config);
$from_name = "yangheping";//发件人名称
$email_subject = "测试email发送";//标题
$email_body = "测试email发送";//内容
$this->email->from('xxxx.com', $from_name);
$this->email->to('xxx@qq.com');//to
$this->email->subject($email_subject);
$this->email->message($email_body);
$this->email->set_newline("\r\n");
if (!$this->email->send()){
show_error($this->email->print_debugger());
return false;
}else{
echo 'ok'; return true;
}
}
}