Codeigniter 使用Gmail 发送邮件设置

1.新建 application/config/email.php    
(可视作---用同名文件设定/system/library/Email.php的参数)

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');  
/* 
| ------------------------------------------------------------------- 
| EMAIL CONFING 
| ------------------------------------------------------------------- 
| Configuration of outgoing mail server. 
| */   
$config['protocol']='smtp';  
$config['smtp_host']='ssl://smtp.googlemail.com';  
$config['smtp_port']='465';  
$config['smtp_timeout']='30';  
$config['smtp_user']='your gmail email';  
$config['smtp_pass']='your gmail password';  
$config['charset']='utf-8';  
$config['newline']="\r\n";
$config['mailtype']="html"; 
  
/* End of file email.php */  
/* Location: ./system/application/config/email.php */
2. 在某个Controller的某个function下设置内容发送邮件:
$this->load->library('email');

$this->email->from('[email protected]', 'Your Name');
$this->email->to('[email protected]'); 
$this->email->cc('[email protected]'); 
$this->email->bcc('[email protected]'); 

$this->email->subject('Email Test');
$this->email->message('Testing the email class.'); 

$this->email->send();

echo $this->email->print_debugger();

你可能感兴趣的:(Codeigniter 使用Gmail 发送邮件设置)