[eluser]joehopkins[/eluser]
Hi,
I'm sending an Email from localhost - everything works except the HTML is sent as text:
email.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'mail';
//$config['protocol'] = 'smtp';
$config['smtp_host'] = 'localhost';
$config['email_address'] = '[email protected]';
$config['email_name'] = 'Localhost test';
$config['mailtype'] = 'html';
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
model
Code:
$message='<html>
<head>
<meta charset="utf-8" />
<title>CRM Username and Password</title>
<style type="text/css" media="screen">
body {
font-family: Verdana, Arial;
}
</style>
</head>
<body>
<p>Hello '.$forename.'</p>
<p>Your username and password to log into the CRM system is:</p>
<p>username: <strong>'.$email.'</strong><br />
password: <strong>'.$password.'</strong></p>
<p>To log in, go to '.base_url().'</p>
<p>You can change your password after you log in.</p>
</body>
</html>
';
$txt_message = '
Hello '.$forename.'
Your username and password to log into the CRM system is:\n\n
username: '.$email.'\n
password: <strong>'.$password.'\n\n
To log in, go to '.base_url().'\n\n
You can change your password after you log in.
';
$this->load->library('email');
$this->email->from('crm@localhost', 'AAA CRM Manager');
$this->email->to($email);
$this->email->subject('CRM Username and Password');
$this->email->message($message);
$this->email->set_alt_message($txt_message);
if ( ! $this->email->send())
{
// Generate error
return 'Error: user WAS added to database but there was a problem sending the confirmation email with login details.'.$this->email->print_debugger();
}
else
{
$this->Log_model->add_to_log('User ('.$email.') added.');
return 'New user added.'.$this->email->print_debugger();
}
Debug output
Code:
Your message has been successfully sent using the following protocol: mail
From: "AAA CRM Manager"
Return-Path:
Reply-To: "crm@localhost"
X-Sender: crm@localhost
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4e3c00f1d7114@localhost>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?CRM_Username_and_Password?=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8" />
<title>CRM Username and Password</title>
<style type="text/css" media="screen">
body {
font-family: Verdana, Arial;
}
</style>
</head>
<body>
<p>Hello Joe</p>
<p>Your username and password to log into the CRM system is:</p>
<p>username: <strong>[email protected]</strong><br />
password: <strong>4z328i4h</strong></p>
<p>To log in, go to http://localhost/awo/www/</p>
<p>You can change your password after you log in.</p>
</body>
</html>
Notice the 'Content-Type: text/plain'. The email I receive is just the HTML code.
What am I doing wrong?
Many thanks.
Joe