html email help

#1
[eluser]dadamssg[/eluser]
I wrote a simple controller script to try to get my html emails working. I can't figure it out though. The view is a form that has an email and body form inputs. I'm submitting complete, really simple, html pages. Heres my controller

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Email_tester extends CI_Controller {

public function __construct()
{
    parent::__construct();
$this->load->library(array('session','form_validation','email'));
}

function index()
{
  
  $this->form_validation->set_rules('email', 'email', 'xss_clean|trim|required|valid_email');
  $this->form_validation->set_rules('body', 'body', 'trim|required');
  $this->form_validation->set_error_delimiters('', '<br/><br/>');

  if($this->form_validation->run() == TRUE)
  {
   $email      = $this->input->post('email');
   $email_body = $this->input->post('body');

   $email_config['mailtype'] = 'html';
   $this->email->initialize($email_config);

   $this->email->from('[email protected]', 'Test');
   $this->email->to($email);        
   $this->email->subject("Email Test");
   $this->email->message($email_body);
   $this->email->send();
  
   $session['message'] = "Email Sent.<br/><br/>";
   $this->session->set_userdata($session);
  
   redirect('email_tester');
  }
  else
  {
   $data['title'] = "";
   $data['login'] = "";
  
   $this->load->view('header_view', $data);
   $this->load->view('Test/email_tester', $data);
   $this->load->view('footer_view');
  }

}

}
?&gt;

And i just tried sending this through the textarea in my form...

Quote:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
&lt;html&gt;
&lt;head&gt;
&lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type"&gt;&lt;/meta>
&lt;style type="text/css"&gt;
body{
background: #888;
}
#content{
margin: 0 auto;
width: 600px;
background: #fff;
padding: 30px;
text-align: center;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
<div id='content'>
<p>Testing<br/>Please work</p>
</div>
&lt;/body&gt;
&lt;/html&gt;

I'm sending it to my gmail email account. I see that a text and an html version are being sent but gmail isn't displaying it as html, it's all text. What am i doing wrong?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.