关于此问题,我已检查堆栈溢出的类似链接。但我无法找到任何解决方案。附件不工作的Codeigniter电子邮件
Link的我已经检查
- Codeigniter send email with attach file
- Code Igniter -> attach email
- codeigniter send pdf file as email attachment
问题
何时发送邮件,我收到邮件。与所有细节。但附件不起作用。
尝试
我赞同的文件名,它从打印控制器中的文件名
代码
$upcon['upload_path'] = 'cv_uploads/';
$upcon['max_size'] = '5120';
$upcon['allowed_types'] = 'pdf|doc|txt|zip|rtf|docx';
$this->load->library('upload', $upcon);
if(!$this->upload->do_upload('file')){
echo $this->upload->display_errors();
}
else{
$up_data = $this->upload->data();
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$name = $this->input->post('name');
$email = $this->input->post('email');
$address = $this->input->post('address');
$residence = $this->input->post('residence');
$office = $this->input->post('office');
$mobile = $this->input->post('mobile');
$position = $this->input->post('position');
$comment = $this->input->post('comment');
$file_name= '/cv_uploads/'.$up_data['file_name'];
$this->email->from('[email protected]', 'site name');
$this->email->to('[email protected]');
$this->email->attach($file_name);
$this->email->subject('Subject');
$this->email->message("Message ");
if(!$this->email->send())
{
$data['sent_mail'] = false;
}
else{
$data['sent_mail'] = "true";
}
print_r($file_name);
}
我收到的邮件没有附件。任何想法??
添加绝对路径,而不是相对路径;) –
@ManinderpreetSingh你能告诉我的代码? –
任何帮助?????? –