我在codeigniter中有一个自动加载的库
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Send_email {
private $CI;
public $from_email;
public $from_name;
public $reply_to;
public $to_email;
public $subject;
public $message;
public function __construct() {
$this->CI =& get_instance();
$this->CI->load->library('email');
}
public function send_email($f_email,$f_name,$t_email,$rep_to,$sub,$msg){
$this->from_email = $f_email;
$this->from_name = $f_name;
$this->to_email = $t_email;
$this->reply_to = $rep_to;
$this->subject = $sub;
$this->message = $msg;
$this->CI->email->from($this->from_email, $this->from_name);
$this->CI->email->to($this->to_email);
$this->CI->email->reply_to($this->reply_to);
$this->CI->email->subject($this->subject);
$this->CI->email->message($this->message);
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "****@gmail.com";
$config['smtp_pass'] = "****";
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->CI->email->initialize($config);
if($this->CI->email->send()){
return TRUE;
}else{
return $this->CI->email->print_debugger();
}
}
}
?>
从控制器调用它时
$this->send_email->send_email(......)
调用此方法后,我收到此错误 无法发送没有&#34; From&#34;我怎么能解决这个问题?
答案 0 :(得分:0)
检查$ this-&gt; from_email值是否正确
答案 1 :(得分:-1)
echo $this->email->print_debugger();
将返回标题,主题和&amp;身体内容