您好,登錄后才能下訂單哦!
前幾天用CI寫項(xiàng)目用到了一個(gè)發(fā)送郵件函數(shù),今天把它貢獻(xiàn)出來,希望有用,什么都不說了,直接上方法
public function sendMail() {
$config['protocol'] = 'smtp';//采用smtp方式
$config['smtp_host'] = 'smtp.126.com';
$config['smtp_user'] = 'mytest@126.com';//你的郵箱帳號(hào)
$config['smtp_pass'] = 'mytest123';//你的郵箱密碼
//$config['smtp_pass'] = 25;
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
$this->load->library('email');//加載email類
$this->email->initialize($config);//參數(shù)配置
$this->email->from('lijunhua19862008@126.com', '我是發(fā)件人 陳文');
$this->email->to('my@test.com');
//$this->email->cc('another@another-example.com');
//$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test to guijia');
$this->email->message('Testing the email class.');
$this->email->attach('static/upfile/'.$sfile.'');
//顯示發(fā)送郵件的結(jié)果,加載到res_view.php視圖文件中
if(!$this->email->send()){
$data="<font color='red' size='10px'>郵件發(fā)送失敗,可能是由您的發(fā)件人或者密碼填寫不匹配造成</font>";
} else {
$data="<font color='red' size='10px'>郵件發(fā)送成功</font>";
}
echo $data;
echo $this->email->print_debugger();
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。