1. 程式人生 > >CI框架傳送郵件

CI框架傳送郵件

1、使用QQ郵箱

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.qq.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '************';//授權碼,不是QQ郵箱密碼
$config['smtp_port'] = 465;
$config['smtp_crypto'] = 'ssl';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";//必須是雙引號

$this->load->library('email');
$this->email->initialize($config);
$this->email->from('
[email protected]
', 'TEST'); //傳送方 $this->email->to('[email protected]'); //接收方 $this->email->subject('SUBJECT'); //主題 $this->email->message('MESSAGE'); //郵件內容 $this->email->send(); //傳送

2、使用163郵箱

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = '
[email protected]
'; $config['smtp_pass'] = '************';//授權碼,不是QQ郵箱密碼 $config['smtp_port'] = 465; $config['smtp_crypto'] = 'ssl'; $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; $config['crlf'] = "\r\n"; $config['newline'] = "\r\n";//必須是雙引號 $this->load->library('email'); $this->email->initialize($config); $this->email->from('
[email protected]
','TEST'); //傳送方 $this->email->to('[email protected]'); //接收方 $this->email->subject('SUBJECT'); //主題 $this->email->message('MESSAGE'); //郵件內容 $this->email->send(); //傳送

3、使用騰訊企業郵箱

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.exmail.qq.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '******';//授權碼,不是QQ郵箱密碼
$config['smtp_port'] = 465;
$config['smtp_crypto'] = 'ssl';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";//必須是雙引號

$this->load->library('email');
$this->email->initialize($config);
$this->email->from('[email protected]','TEST'); //傳送方
$this->email->to('[email protected]'); //接收方
$this->email->subject('SUBJECT'); //主題
$this->email->message('MESSAGE'); //郵件內容
$this->email->send(); //傳送