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 做过TCL海信电视小米电视相关影视会员软件私我
  • ¥15 Mapreduce是正常的,在运行其他jar包时并没有任何问题,只是在做LogCount.jar 时出的问题。如图所示
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢
  • ¥15 docker部署Mongodb后输入命令报错?
  • ¥15 将下列流程图转变成python程序代码
  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序
  • ¥15 如何解决Excel中dependent dropdown list 的问题