我想弄清楚为什么我的用户正在接收从我的网络应用程序发送的电子邮件的重复副本。以下是发送电子邮件的代码:
function _send_user_email($to, $subject, $message) {
$this->load->library('email');
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['protocol'] = 'sendmail';
$this->email->initialize($config);
$this->email->from('support@mysite.com', 'Customer Service');
$this->email->reply_to('support@mysite.com', 'Customer Service');
$this->email->to($to);
$this->email->bcc('support@mysite.com');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
if ( ! $this->email->send())
{
echo $this->email->print_debugger();
exit;
}
}
此代码是否有任何错误可能导致邮件被发送两次?
答案 0 :(得分:6)
显然,因为
$this->email->send();
if ( ! $this->email->send())
您要发送两次电子邮件。删除第一个电话,只留下if
声明中的一个