2016-09-14 2 views
0

Ich sende eine E-Mail, indem ich die E-Mail aus einer Ansichtsdatei lade.E-Mail wird mit HTML-Tags anstelle von Klartext gesendet

Meine E-Mail mit HTML-Tags wie folgt gesendet:

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

ich es will, ohne die Tags gesendet werden, im Klartext:

Hi mom! 

Siehe Code unten:

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

meinst du der Empfänger sieht ' Hallo Mama! 'anstelle von' Hallo Mama! '? –

+0

Ja, ist mein Code falsch? – erinr

+1

Sie haben CI nicht mitgeteilt, dass Sie eine HTML-E-Mail senden, daher wurde der HTML-Code als einfacher Text ausgegeben und als solcher gerendert. –

Antwort

0

Sie müssen CI den Mail-Typ mitteilen:

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

oder

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

Vor $this->email->send() Aufruf.

+0

Ich löse dieses Problem bereits mit $ this-> email-> set_mailtype ("html"), bevor Sie kommentieren. immer noch danke und ich überlege dir deinen code. – erinr

Verwandte Themen