通过Codeigniter发送带有附件的电子邮件时出错

通过Codeigniter发送带有附件的电子邮件时出错,codeigniter,email,xampp,localhost,send,Codeigniter,Email,Xampp,Localhost,Send,我正试图通过Codeigniter发送一封带有附件的电子邮件。问题是它在运行时附加文件,但只发送指定的内容而忽略附件 我曾尝试将其上传到“uploads”文件夹,并将其与内容一起发送,但它只发送消息,并显示下面提到的错误 类电子邮件发送扩展CI控制器{ public function send() { $file_data = $this->upload_file(); $to = $this->input->post('from'); // User e

我正试图通过Codeigniter发送一封带有附件的电子邮件。问题是它在运行时附加文件,但只发送指定的内容而忽略附件

我曾尝试将其上传到“uploads”文件夹,并将其与内容一起发送,但它只发送消息,并显示下面提到的错误

类电子邮件发送扩展CI控制器{

public function send()
{
    $file_data = $this->upload_file();
    $to =  $this->input->post('from');  // User email pass here
    $subject = 'Offer from Saremco Impex';
    $from = 'myemail';// Pass here your mail id



        $emailContent = '<!DOCTYPE><html><head></head><body><table width="600px" style="border:1px solid #cccccc;margin: auto;border-spacing:0;"><tr><td style="background:#ffa500;padding-left:3%"><!--<img src="http://localhost/crud/assets/logo/eoffice_logo.png" width="300px" vspace=10 />--></td></tr>';
        $emailContent .= '<tr><td style="height:20px"></td></tr>';


        $emailContent .= $this->input->post('message');  //   Post message available here


        $emailContent .= '<tr><td style="height:20px"></td></tr>';
        $emailContent .= "<tr><td style='background:#ffa500;color: #999999;padding: 2%;text-align: center;font-size: 13px;'><p style='margin-top:1px;'><a href='http://saremcoimpex.com/' target='_blank' style='text-decoration:none;color: #60d2ff;'>www.saremcoimpex.com</a></p></td></tr></table></body></html>";



    $config['protocol']    = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.gmail.com';
    $config['smtp_port']    = 465;
    $config['smtp_timeout'] = 60;

    $config['smtp_user']    = 'myusername';
    $config['smtp_pass']    = 'mypass';

    $config['charset']    = 'utf-8';
    $config['newline']    = "\r\n";
    $config['mailtype'] = 'html'; // or html
    $config['validation'] = FALSE; // bool whether to validate email or not

    //$file_path = 'uploads/' . $file_name;


    $this->load->library('email', $config);
    $this->email->initialize($config);
    $this->email->set_mailtype("html");
    $this->email->from($from);
    $this->email->to($to);
    $this->email->subject($subject);
    $this->email->message($emailContent);
    $this->email->attach($file_data['full_path']);
    $this->email->send();
/*    $this->session->set_flashdata('success','Mail has been sent successfully');
    return  redirect(base_url().'index.php/user/');*/
    echo $this->email->print_debugger();

}

function upload_file()
{
    $config['upload_path'] = './uploads';
    $config['allowed_types'] = 'doc|docx|pdf';
    $this->load->library('upload', $config);
    if($this->upload->do_upload('resume'))
    {
        return $this->upload->data();
    }
    else
    {
        return $this->upload->display_errors();
    }
}
公共函数send()
{
$file_data=$this->upload_file();
$to=$this->input->post('from');//用户在此处发送电子邮件
$subject='萨雷姆科弹劾公司的报价';
$from='myemail';//在这里传递您的邮件id
$emailContent='';
$emailContent.='';
$emailContent.=$this->input->post('message');//此处提供post message
$emailContent.='';
$emailContent.=“

load->library('email',$config); $this->email->initialize($config); $this->email->set_mailtype(“html”); $this->email->from($from); $this->email->to$to; $this->email->subject($subject); $this->email->message($emailContent); $this->email->attach($file_data['full_path']); $this->email->send(); /*$this->session->set_flashdata('success','Mail has sent successfully'); 返回重定向(base_url().'index.php/user/')*/ echo$this->email->print_debugger(); } 函数上传_文件() { $config['upload_path']='./uploads'; $config['allowed_types']='doc | docx | pdf'; $this->load->library('upload',$config); 如果($this->upload->do_upload('resume')) { 返回$this->upload->data(); } 其他的 { 返回$this->upload->display_errors(); } }

}


消息:非法的字符串偏移量“full_path”这是一个错误,从技术上讲应该是有效的。可能您的上传工作不正常,如果display_errors()返回字符串,则可能是您的错误原因