发送的文件夹

时间:2016-08-16 10:10:38

标签: php codeigniter email

我现在可以发送电子邮件,但我的问题是当我使用雅虎或Outlook帐户时,发送的邮件没有反映在已发送的文件夹中,但邮件可以在收件人的收件箱中看到:

public function send_mail(){

 $this->load->helper('path');
// Storing submitted values
$sender_email = 'test@yahoo.com';
$user_password = 'test';
$receiver_email = $this->input->post('to_email');
$username = 'test';
$subject = $this->input->post('subject');
$message = $this->input->post('message');
$attachment = $this->input->post('upload');



// Configure email library
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.mail.yahoo.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = $sender_email;
$config['smtp_pass'] = $user_password;
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

// Load email library and passing configured values to email library
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Sender email address
$this->email->from($sender_email, $username);
// Receiver email address
$this->email->to($receiver_email);
// Subject of email
$this->email->subject($subject);
// Message in email
$this->email->message($message);
//attachment
$this->load->library('upload');

$size = $_FILES['upload']['size'][0];


if($size>0){
  $aConfig['upload_path'] = './uploads';
  $aConfig['allowed_types']    = '*';
  $aConfig['max_size']     = '250000';
  $aConfig['max_width']        = '1280';
  $aConfig['max_height']       = '1024';

  $files = $_FILES;
  $cpt = count($_FILES['upload']['name']); 
  for($i=0; $i<$cpt; $i++)
  {           

      $_FILES['upload']['name']= $files['upload']['name'][$i];
      $_FILES['upload']['type']= $files['upload']['type'][$i];
      $_FILES['upload']['tmp_name']= $files['upload']['tmp_name'][$i];
      $_FILES['upload']['error']= $files['upload']['error'][$i];
      $_FILES['upload']['size']= $files['upload']['size'][$i];   

      $this->upload->initialize($aConfig);
      if($this->upload->do_upload('upload'))
      {
        $ret = $this->upload->data();

      } else {
       print_r('ATTACHMENT NOT SUPPORTED');die();
      }
      $pathToUploadedFile = $ret['full_path'];
      $this->email->attach($pathToUploadedFile);

  }

  $path = $ret['file_path'];
  $files = glob($path.'*');

  foreach($files as $file){
    if(is_file($file)){
      unlink($file);
    }
  }

}

if ($this->email->send()) {

  // echo '<script>alert("Email successfully sent!");</script>';
    // $this->load->view('BASE_URL . "".$this->uri->segment(1)."/compose');
   $this->email->clear(TRUE);
   $this->session->set_flashdata('message', 'sent_msg');
   redirect(BASE_URL.'tenant/compose');
} else {

   // $this->load->view('tenant/compose');
  $this->email->clear(TRUE);
  $this->session->set_flashdata('message', 'Email not sent!');
   redirect(BASE_URL.'tenant/compose');
}

}

提前谢谢你们

0 个答案:

没有答案