Php Codeigniter | 15%的HTML电子邮件是空白的

Php Codeigniter | 15%的HTML电子邮件是空白的,php,codeigniter,email,Php,Codeigniter,Email,目前有一个表单,用户上传4个附件。这些附件将上载到服务器,然后附加到电子邮件,然后通过电子邮件发送 我有一切设置和在大多数测试的电子邮件附件发送正确。但是,有时电子邮件会以空白形式发送。一个用户收到一封空白电子邮件,每当我测试时,它就成功了 不知道为什么。。我使用的是CodeIgniter,不明白为什么有些文件会空白并正确发送 我正在尝试使用:echo$this->email->print_debugger() 然而,在我这方面总是成功的 要点: 此处空白电子邮件的要点: 我相信,这是因为。域名

目前有一个表单,用户上传4个附件。这些附件将上载到服务器,然后附加到电子邮件,然后通过电子邮件发送

我有一切设置和在大多数测试的电子邮件附件发送正确。但是,有时电子邮件会以空白形式发送。一个用户收到一封空白电子邮件,每当我测试时,它就成功了

不知道为什么。。我使用的是CodeIgniter,不明白为什么有些文件会空白并正确发送

我正在尝试使用:echo$this->email->print_debugger()

然而,在我这方面总是成功的

要点:

此处空白电子邮件的要点:

我相信,这是因为。域名托管在domain.com上,但电子邮件(来自)是另一个。参见日志中的X-抗虐待

function test_upload()
{
  $this->load->view('am_header');
  $this->load->library('email');
  $this->load->helper('date');
  date_default_timezone_set('America/Jamaica');
  $dateTime = date('Y-m-d H:i:s');
  $this->load->library('upload');
  $this->email->subject('My Form');
  $this->email->from('form@mydomain.com', 'Life Form');
  $this->email->set_mailtype("html");

    // personal
  $data['date'] = $dateTime;

  $data['terms'] = $this->input->post('terms');
  $data['first_name'] = $this->input->post('first_name');
  $data['middle_name'] = $this->input->post('middle_name');
  $data['last_name'] = $this->input->post('last_name');
  $nummy =  random_string('alnum', 16);

  $data['nummy'] = $nummy;
  $files = $_FILES;
  $cpt = count($_FILES['userfile']['name']);
  $vary = array('PHOTO','RESUME','JOB','PHOTO2');
  for($i=0; $i<$cpt; $i++)
  {
      $_FILES['userfile']['name']= $files['userfile']['name'][$i];
      $_FILES['userfile']['type']= $files['userfile']['type'][$i];
      $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
      $_FILES['userfile']['error']= $files['userfile']['error'][$i];
      $_FILES['userfile']['size']= $files['userfile']['size'][$i];

        $new_name = $vary[$i] .$nummy .$_FILES["userfile"]['name'];
        $this->upload->initialize($this->test_set_upload_options($new_name));

      if ( ! $this->upload->do_upload()){
        $error = array('error' => $this->upload->display_errors());
        redirect('main/error_contact');
      }
      else{
          $this->email->attach("testuploads/" . $new_name);
      }
  }

  $this->email->to('redme@myemail.com');
  $this->main_model->add_records_test($data);
  $message = $this->load->view('contact_template',$data,TRUE); // this will return you html data as message
  $this->email->message($message);

    if ($data2['smile']=='') {
      if ($this->email->send() ) {
        redirect('main/thanks_contact');
        echo $this->email->print_debugger();
    }
      }else{
        echo $this->email->print_debugger();
        redirect('main/error_contact');
    }
}

private function test_set_upload_options($new_name)
{
    //upload an image options
    $config = array();
    $config['upload_path'] = './testuploads/';
    // $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['allowed_types'] = 'gif|jpg|png|pdf|jpeg|zip|doc|docx';
    $config['max_size']      = '0';
    $config['overwrite']     = FALSE;
    $config['file_name'] = $new_name;

    return $config;
}
功能测试_上传()
{
$this->load->view('am_header');
$this->load->library('email');
$this->load->helper('date');
日期默认时区设置(“美国/牙买加”);
$dateTime=日期('Y-m-d H:i:s');
$this->load->library('upload');
$this->email->subject(“我的表单”);
$this->email->from($this)form@mydomain.com","生命形式",;
$this->email->set_mailtype(“html”);
//私人的
$data['date']=$dateTime;
$data['terms']=$this->input->post('terms');
$data['first_name']=$this->input->post('first_name');
$data['middle_name']=$this->input->post('middle_name');
$data['last_name']=$this->input->post('last_name');
$nummy=随机字符串('alnum',16);
$data['nummy']=$nummy;
$files=$\u文件;
$cpt=计数($_文件['userfile']['name']);
$vary=数组('PHOTO','RESUME','JOB','PHOTO2');
对于($i=0;$iupload->initialize($this->test\u set\u upload\u options($new\u name));
如果(!$this->upload->do_upload()){
$error=array('error'=>$this->upload->display_errors());
重定向(“主/错误触点”);
}
否则{
$this->email->attach(“testuploads/”$new_name);
}
}
$this->email->to($this)redme@myemail.com');
$this->main\u model->add\u records\u test($data);
$message=$this->load->view('contact_template',$data,TRUE);//这将以消息的形式返回html数据
$this->email->message($message);
如果($data2['smile']=''){
如果($this->email->send()){
重定向(“主/感谢联系人”);
echo$this->email->print_debugger();
}
}否则{
echo$this->email->print_debugger();
重定向(“主/错误触点”);
}
}
专用功能测试\设置\上传\选项($new\名称)
{
//上载图像选项
$config=array();
$config['upload_path']='./testuploads/';
//$config['allowed_types']='gif | jpg | png | jpeg';
$config['allowed_types']='gif | jpg | png | pdf | jpeg | zip | doc | docx';
$config['max_size']='0';
$config['overwrite']=FALSE;
$config['file\u name']=$new\u name;
返回$config;
}

您并不总是打印
print\u debugger()
调用

它可以简化为

// $data2 is never defined, so remove that if which is always TRUE
// if ($data2['smile']=='') {

$status = $this->email->send();
echo $this->email->print_debugger();

if ($status) {
    redirect('main/thanks_contact');
} else {
    redirect('main/error_contact');
}

你检查过错误日志了吗?可能是php或页面的问题导致某些变量为空。在debian linux系统(ubuntu)上错误日志位于
/var/log/apache2/error.log
。其他系统也会类似。消息中可能有不寻常的字符或标记。告诉用户只发送附件而不发送消息。转义电子邮件正文。可能是电子邮件客户端…嘿@JonathanKuhn-应用程序当前位于主域的文件夹中,有一个ap应用程序错误,但只包含特定于应用程序的错误,没有显示任何内容。检查rootHey@cssBlaster21895当前仅上载附件并输入一个字段时,该字段仍然为空。我在想,如果附件在电子邮件发送之前上载时间过长,那么实际上是上载到服务器成功。在上传文件之前,不会调用php页面。文件作为请求的一部分发送。在发送请求之前,响应甚至不会启动。因此,如果文件花费的时间太长,它甚至无法使用php脚本发送电子邮件。可能是文件太大,因此电子邮件无法发送或者像cssBlaster说的那样。电子邮件是以html电子邮件的形式发送的吗?如果有php错误,php错误日志仍然应该写入。我更好奇的是php错误而不是应用程序错误。