1

我试图弄清楚为什么我的用户会收到从我的 Web 应用程序发送的电子邮件的重复副本。这是发送电子邮件的代码:

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;
    } 
} 

此代码是否有任何问题可能导致消息被发送两次?

4

1 回答 1

6

显然,由于

$this->email->send();
    if ( ! $this->email->send())

您要发送两次电子邮件。删除第一个调用,只保留if语句中的一个

于 2013-03-11T16:03:49.050 回答