[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');
}
}
}
?>
And i just tried sending this through the textarea in my form...
Quote:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta>
<style type="text/css">
body{
background: #888;
}
#content{
margin: 0 auto;
width: 600px;
background: #fff;
padding: 30px;
text-align: center;
}
</style>
</head>
<body>
<div id='content'>
<p>Testing<br/>Please work</p>
</div>
</body>
</html>
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?