kwangu

Send Email With Attachment Codeigniter

Jun 9th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. public function sendEmail()
  2.  {
  3.     if($this->input->post('send_email') == 'send_email'){
  4.              $this->load->library('email');
  5.              
  6.               $config['upload_path'] = './uploads/';
  7.               $config['allowed_types'] = 'gif|jpg|png';
  8.               $config['max_size'] = '100000';
  9.               $config['max_width']  = '1024';
  10.               $config['max_height']  = '768';
  11.  
  12.              $this->load->library('upload', $config);
  13.              $this->upload->do_upload('attachment');
  14.              $upload_data = $this->upload->data();
  15.              
  16.              $this->email->attach($upload_data['full_path']);
  17.              $this->email->set_newline("\r\n");
  18.              $this->email->set_crlf("\r\n");
  19.              $this->email->from('only4ututorials@gmail.com'); // change it to yours
  20.              $this->email->to($this->input->post('email_id')); // change it to yours
  21.              $this->email->subject($this->input->post('subject'));
  22.              $this->email->message($this->input->post('body'));
  23.              if ($this->email->send()) {
  24.                  echo "Mail Send";
  25.                  return true;
  26.              } else {
  27.                  show_error($this->email->print_debugger());
  28.              }
  29.     }else{
  30.       $this->load->view('email_view');
  31.     }
  32.  }
  33.  
  34. }
Add Comment
Please, Sign In to add comment