Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter发送内容为空的邮件_Codeigniter_Codeigniter 2 - Fatal编程技术网

Codeigniter发送内容为空的邮件

Codeigniter发送内容为空的邮件,codeigniter,codeigniter-2,Codeigniter,Codeigniter 2,我正在使用codeigniter电子邮件功能发送邮件。 这是代码 $this->email->to($to); $this->email->subject($subject); $this->email->attach($_FILES['attachments']['tmp_name']); $this->email->message($mailcontent); if($this->email->send())

我正在使用codeigniter电子邮件功能发送邮件。 这是代码

 $this->email->to($to);     
 $this->email->subject($subject);
 $this->email->attach($_FILES['attachments']['tmp_name']);
 $this->email->message($mailcontent);
 if($this->email->send())
    {
    return true;
    }
当我在像这样发送之前打印内容时,我发现它一直很好

$this->email->message($mailcontent);
print_r($mailcontent);exit;
     if($this->email->send())
        {
        return true;
        }
但是我收到的邮件是空的。它有主题,但正文是空的。
为什么会发生这种情况?

首先加载电子邮件库:

$this->load->library('email');
第二,在发送邮件支票之后:

if($this->email->send()){
    echo $this->email->print_debugger();die;
}

谢谢@Niloy Saha。。我发现当我尝试发送没有附件的邮件时会发生这种情况,所以我只是把添加附件的代码放在if条件下,它就工作了

if($_FILES['attachments']['tmp_name'])
{   
   $this->email->attach($_FILES['attachments']['tmp_name']);
}
$this->email->message($mailcontent);
if($this->email->send())
{
    return true;
}

我收到的邮件无法定位以下电子邮件附件:您的邮件已使用以下协议成功发送:邮件。所以我试着用附件,效果很好。那么没有附件我怎么能让它工作呢!在顶部写下这行:
$this->email->clear(TRUE)在加载电子邮件库之后。这不起作用。但是当我在if条件下给出附件代码时,它起作用了。您是否随邮件发送附件?在此处重新发布您的代码或更新您的问题。