dqxz96998
dqxz96998
2019-03-06 08:59
浏览 53
已采纳

为什么不通过电子邮件库发送文件附件?

Why the file attachments are not sent to the intended email in the following code?

$this->load->library('email');
$config = array();
$config['charset'] = 'utf-8';
$config['protocol']= "smtp";
$config['mailtype']= "html";
$config['smtp_host']= "mail.domain.com";
$config['smtp_port']= "25";
$config['smtp_timeout']= "5";
$config['smtp_user']= "xxxx";
$config['smtp_pass']= "xxxx";
$config['crlf']="
";
$config['newline']="
";
$config['wordwrap'] = TRUE;

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

$this->email->from('aaaa@bbb.com', 'Name');

$this->email->to('aaaa@bbb.com'); 

$this->email->attach(base_url('path/').$this->input->post('nm_file'));

$this->email->subject('This Subject');

$this->email->message("This Message");

if ($this->email->send()) {
  return true;
} else {
  show_error($this->email->print_debugger());
}

I've tried various ways, from changing ports and smtp, etc...

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongshu4755
    dongshu4755 2019-03-06 09:14
    已采纳

    Use FCPATH path instead of base url:

    Try :

    $this->email->attach(FCPATH."root_folder/folder/".$this->input->post('nm_file'));
    
    点赞 评论

相关推荐