【发布时间】:2016-10-07 08:27:20
【问题描述】:
我正在使用 CodeIgniter 及其默认库。每当我发送电子邮件时,它都会发送两次。有没有人有一些调试指针或提示来解决这个问题?
$this->CI->email->from($this->from, $this->company_name);
$this->CI->email->to($this->to);
$this->CI->email->subject($this->subject);
eval("\$message = \"".$this->message."\";");
$this->CI->email->message($this->message);
if($attachment != "")
{
$attac_exp=explode(",",$attachment);
foreach($attac_exp as $key=>$value)
{
if($value != '')
{
$this->CI->email->attach(getcwd()."/attachments/".$value);
}
}
}
$this->CI->email->send();
$this->CI->email->clear(true);
我现在已经用 SMTP 配置了 sendmail。
如果我尝试通过命令行发送电子邮件,我只会收到一封电子邮件。据我所知,问题一定出在 CodeIgniter 上。我已经对此进行了研究。
【问题讨论】:
-
我在 phalcon 框架中遇到了类似的问题,对于我的消息正文,我不得不暗示 ob_start() 和 ob_clean 并清除消息......在 codeigniter 中有类似的东西:send([ $auto_clear = TRUE]),也许会有所帮助
-
谢谢丹尼斯,是的,我看到了,我已经把它放在我的代码中,但不知何故它对我不起作用
-
显示您发送此邮件的控制器代码或型号代码,因为我认为您调用此函数两次...
-
我在发帖前还要仔细检查这里没有多次调用这个函数
标签: php codeigniter email