//以下为一个简单的发送函数:
function email()
{$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = 'phpddt1990@163.com';//这里写上你的163邮箱账户
$config['smtp_pass'] = 'phpddt;';//这里写上你的163邮箱密码
$config['mailtype'] = 'html';
$config['validate'] = true;
$config['priority'] = 1;
$config['crlf'] = "\r\n";
$config['smtp_port'] = 25;
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from('phpddt1990@163.com', '合肥学院青年志愿者联合会');//发件人
$this->email->to('987044391@qq.com');
$this->email->message('哈哈,测试邮件发送');
$this->email->send();
echo $this->email->print_debugger();
}
//下面研究怎么发送html邮件:
$config['mailtype'] = 'html'; //这样设置为HTML类型
$this->email->message('<font color=red>Testing the email class.</font>');
试一下就知道可以了!
//利用邮件模板发送邮件
邮件模板一般是存放在数据库当中的,只要根据模版名称在相应的数据库中查找出对应的模版
并替换掉相关的变量即可。
如以下这样一个函数:
$type代表模板名称,$replace为要替换的变量值
getEmailTemplateByType ( $type, $replace = array())
该函数一般放在公共函数库当中。