在codeigniter上发送电子邮件失败,没有错误

时间:2018-12-12 10:43:54

标签: codeigniter

在过去的几个小时里,我试图理解为什么我的脚本不发送电子邮件。

在生成电子邮件内容的末尾,我使用此代码发送

if ($this->email->send()) 
{
            //all is fine
}
else
{ 
//we have a problem 
}

每次都认为一切正常,电子邮件地址,内容等,在任何情况下send()命令都不会返回失败。

这可能是什么原因,或者我如何进一步解决问题?

在我的服务器日志文件中,我也看不到任何想法。

希望有人有主意...

是否可以输出所有当前的电子邮件设置?

1 个答案:

答案 0 :(得分:2)

尝试此操作通过 localhost

function sendMail()
{
    $config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'xxx@gmail.com', // change it to yours
  'smtp_pass' => 'xxx', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

        $message = '';
        $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('xxx@gmail.com'); // change it to yours
      $this->email->to('xxx@gmail.com');// change it to yours
      $this->email->subject('Resume from JobsBuddy for your Job posting');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

}
相关问题