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 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'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog