我想使用codeignator发送电子邮件,但邮件已正确发送,但没有保存在我已将代码放在下面的send文件夹中。
public function sendMail()
{
$data=array('fromEmail'=>'xyz@gmail.com','to'=>'abc@gmail.com','cc'=>'','subject'=>'Login Count','template'=>"Any msg");
$localhost = array(
'127.0.0.1',
'::1'
);
$this->load->library('email');
$config = Array(
/*'charset'=>'utf-8',
'wordwrap'=> TRUE,
'mailtype' => 'html'*/
'mailtype' => 'html',
'priority' => '3',
'charset' => 'iso-8859-1',
'validate' => TRUE ,
'newline' => "\r\n",
'wordwrap' => TRUE
);
if(in_array($_SERVER['REMOTE_ADDR'], $localhost))
{
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.office365.com';
$config['smtp_port']='465';
$config['smtp_user']='xyz@gmail.com';
$config['smtp_pass']='****';
$config['mailtype']='html';
}
$this->email->initialize($config);
/*if(isset($data['fromEmail']) && $data['fromEmail']!='')
{
$fromEmail = $this->getValue($this->db->dbprefix('admin_users'),"email"," `id` = '1' ");
}*/
$fromName = 'Creosouls Team';
$this->email->clear(TRUE);
$this->email->to($data['to']);
if(isset($data['cc']) && $data['cc'] !='')
{
$this->email->cc($data['cc']);
}
$this->email->from($data['fromEmail'],$fromName);
$this->email->subject($data['subject']);
$this->email->message($data['template']);
$this->email->send();
echo $this->email->print_debugger();
pr($data);
// if($this->email->send())
// return true;
// else
// return false;
}