【问题标题】:Codeigniter, error when send multiple emailCodeigniter,发送多封电子邮件时出错
【发布时间】:2017-05-12 10:39:30
【问题描述】:

我正在使用时事通讯方法,但是当我发送多封邮件时,从第二封邮件到最终邮件都失败了。不知道哪里出了问题。

这是我的代码:

$this->load->library('email');

            $this->email->from('newsletter@xxxxxx.yy', 'xxxxxx');
            $data = array();
            $data["content"] = $contenuto;

            foreach($result->result() as $row){
                $this->email->clear(TRUE);
                $data["footer_link"] = "<p><a href=\"http://localhost/xxxxx/public/landing/unsub/". $row->email ."\">Clicca qui</a> per disinscriverti dalla newsletter</p>"; //unsubscribe newsletter

                $this->email->to($row->email);
                $body = $this->load->view("templates/entire_page.php", $data, TRUE);

            $this->email->subject($subject);
            $this->email->message($body);
            $this->email->set_mailtype("html");

            if($this->email->send()){
                echo $row->email.': email inviata con successo!<br>'; //email sent
            }else{
                echo $row->email.": Impossibile inviare l'email: Errore.<br>"; //email not sent
            }

            }

我的错误示​​例:

dunkey@munkey.com: email inviata con successo! (sented)
dunkey@chicken.com: Impossibile inviare l'email: Errore. (not sented)
dunkey@csgo.com: Impossibile inviare l'email: Errore. (not sented)

我很抱歉这篇文章中的意大利语,但我用相对翻译评论了它。 我希望我很清楚,在此先感谢您的帮助。

【问题讨论】:

标签: php codeigniter email


【解决方案1】:

我解决了。我将“来自”移到“清除”之后。

代码如下:

        $data = array();
        $data["content"] = $contenuto;

        foreach($result->result() as $row){
        $this->email->clear(TRUE);
        $this->email->from('newsletter@xxxxxx.yy', 'xxxxxx');
        // ...other code...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 2015-12-28
    • 2012-11-21
    • 2012-12-12
    相关资源
    最近更新 更多