2016-09-14 114 views
0

我通過從視圖文件加載電子郵件發送郵件。正在用html標記而不是純文本發送郵件

我的電子郵件地址與HTML標籤發送這樣的:

<html><body>Hi mom!</body></html> 

我希望它是沒有標籤發送,以純文本格式:

Hi mom! 
下面

見代碼:

public function savepromo(){ 

     $allemail = $this->AdminModel->getallemail(); 

     $data['promos'] = $this->AdminModel->getallpromos(); 

     $totalrows = $this->AdminModel->countemail(); 
      if ($totalrows > 0) { 
       $limit = 10; 
       $totalbatches = ceil($totalrows/$limit); 

        for ($batch = 0; $batch < $totalbatches; $batch++){ 

         $offset = $batch * $limit; 

         $batch_record = array(); 
         $destination = ""; 

         foreach ($this->AdminModel->fetchrecords($limit,$offset) as $value){ 
          array_push($batch_record,$value->email); 
         } 
          $destination = implode(';', $batch_record); 


          $config = array(

          'charset' => 'utf-8', 
          'wordwrap' => TRUE, 
          'mailtype'=> 'html' 
          ); 
          $this->load->initialize($config);        

          $fromemail="[email protected]"; 
          $toemail = $destination; 
          $subject = "THIS IS FOR TESTING PURPOSES DONT MIND THIS MESSAGE!"; 
          $mesg = $this->load->view('email/promomessage',$data,TRUE); 
          $this->load->library('email'); 


          $this->email->from($fromemail, 'MY TESTING EMAIL'); 
          $this->email->to($destination); 

          $this->email->subject($subject); 
          $this->email->message($mesg); 
          $this->email->send(); 
         } 
        } 

     $this->session->set_flashdata('try', '<div class="alert alert-danger text-center">SUCCESS!</div>'); 

     redirect('administrator/createpromo'); 
    } 

} 
+0

你的意思是收件人看到'嗨,媽媽!'而不是'你好媽媽!'? –

+0

是的,我的代碼中是否有任何錯誤? – erinr

+1

你沒有告訴CI你發送的是一個html郵件,所以html就像純文本一樣,並且被呈現爲這樣。 –

回答

0

你必須告訴CI郵件類型:

$this->email->set_mailtype("html"); 

$config['mailtype'] = 'html'; 

在致電$this->email->send()

+0

我在評論之前已經使用$ this-> email-> set_mailtype(「html」)解決了這個問題。還是謝謝,我認爲你的代碼。 – erinr

相關問題