您的位置:首页 > 编程语言 > PHP开发

codeIgniter中发送邮件的调用方法

2016-09-30 14:13 281 查看
function send_mail($subject,$message,$attachFile)
{
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.126.com';
$config['smtp_user'] = 'your email account username';
$config['smtp_pass'] = 'your email account password';
$config['mailtype'] = 'html';
$config['validate'] = true;
$config['priority'] = 1;
$config['crlf'] = "\r\n";
$config['smtp_port'] = 465;
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);

$this->email->from('your email account username', 'your name'); //发件人
$this->email->to($this->mailTo);

$this->email->subject($subject);
$this->email->message($message);
$this->email->attach($attachFile);
$ret = $this->email->send();
var_dump($attachFile,$ret);
echo $this->email->print_debugger();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息