2016-09-14 12 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

関連する問題