邮件功能一次只能运行一次:Codeigniter

时间:2018-09-16 03:32:58

标签: codeigniter

我正在使用Codeigniter电子邮件库发送电子邮件。我在模型中集成了这样的电子邮件设置

public function savedetails($data) {
     $firstmail = $this->sendmail(1, $data);

     $secondmail = $this->sendmail(2, $data);
}

public function sendmail($flag, $data) {
     $this->load->library('email');

    $config = array(
        'protocol' => 'smtp',
        'smtp_host' => $this->config->item('emailhost'),
        'smtp_user' => $this->config->item('emailusername'),
        'smtp_pass' => $this->config->item('emailpassword'),
        'smtp_port' => 25,
        'smtp_crypto' => 'tls',
        'mailtype' => 'html'
    );

    $this->email->initialize($config);

    $this->email->set_newline("\r\n");

    if($flag == 1) {

        $this->email->from('someone@example.com', 'Someone');

        $this->email->to('someone@example.com, 'Someone');

        $this->email->subject('This is a test message');

        $message = $this->load->view('email/firstmail.php', $data, true);

    } else {

        $this->email->from('someone@example.com', 'someone');

        $this->email->to('someone@example.com', 'someone');

        $this->email->subject('This is a test message');

        $message = $this->load->view('email/secondmail.php', $data, true);

    }

    $this->email->message($message);

    return $this->email->send();
}

因此,第一封电子邮件成功发送,但是第二封电子邮件每次都失败。第二封电子邮件不会每次都发送,并且每次都为假,但第一封电子邮件已成功发送。这是什么问题?我如何也可以在Codeigniter中成功发送第二封电子邮件?

0 个答案:

没有答案