【问题标题】:Why the file attachments are not sent via the email library?为什么不通过电子邮件库发送文件附件?
【发布时间】:2019-03-06 08:59:20
【问题描述】:

为什么文件附件没有发送到以下代码中的预期电子邮件?

$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']="\r\n";
$config['newline']="\r\n";
$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());
}

我尝试了各种方法,从更改端口和 smtp 等...

【问题讨论】:

  • 您是否遇到任何错误?你检查过你的日志吗?
  • 您确定,该文件在提及路径上可用吗?
  • 当然是@Ashu
  • @Script47 无错误,此文件夹设置权限 777

标签: php codeigniter email phpmailer codeigniter-3


【解决方案1】:

使用FCPATH 路径而不是基本网址:

试试:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 2015-07-23
    • 2018-07-12
    • 2021-07-18
    • 2010-10-17
    • 2016-07-19
    相关资源
    最近更新 更多