我使用code_eriter 2與tank_auth庫。 名爲user_model它的模型有一個功能(_send_email())來發送電子郵件:codeigniter電子郵件 - >發送兩次發送
function _send_email($type, $email, &$data)
{
$this->load->library('email');
$this->config->set_item('language', 'dutch');
$this->email->set_newline("\r\n");
$this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
//$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->to($email);
$this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
$this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
$this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
if($this->email->send()){
echo "sendit";
}
}
我嘗試從一個控制器調用這個函數是這樣的:
public function email($value='')
{
$this->lang->load('tank_auth', 'dutch');
$this->load->model('user_model');
$data = array("site_name" => "site name");
$this->user_model->_send_email('bestelling_geplaatst', "[email protected]",$data); // send
}
問題電子郵件被髮送兩次到電子郵件地址
任何人遇到這個問題知道在哪裏尋找解決方案(或問題)
更多信息:
我試圖做的方法在我的控制器就像在使用導喜歡這裏的例子:http://ellislab.com/codeigniter/user-guide/libraries/email.html
$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();
這種方法也發送電子郵件的兩倍!
可能是你的郵件功能被調用了兩次......檢查正常。 –
thnx回覆,我發現我的awnser我正在尋找, 問題是谷歌瀏覽器的Firebug精簡版,因爲我在這裏描述: http://stackoverflow.com/a/13972704/1108772 –