Welcome Guest, Not a member yet? Register   Sign In
HTML email sending as Text - Help
#1

[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>
                        &lt;/body&gt;
                        &lt;/html&gt;
                        ';
                        $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">
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;title&gt;CRM Username and Password&lt;/title&gt;
&lt;style type="text/css" media="screen"&gt;
body {
font-family: Verdana, Arial;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
<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>
&lt;/body&gt;
&lt;/html&gt;

Notice the 'Content-Type: text/plain'. The email I receive is just the HTML code.

What am I doing wrong?

Many thanks.

Joe


Messages In This Thread
HTML email sending as Text - Help - by El Forum - 08-05-2011, 08:49 AM
HTML email sending as Text - Help - by El Forum - 08-05-2011, 09:19 AM
HTML email sending as Text - Help - by El Forum - 08-05-2011, 04:58 PM
HTML email sending as Text - Help - by El Forum - 08-06-2011, 08:37 AM
HTML email sending as Text - Help - by El Forum - 08-06-2011, 08:44 AM
HTML email sending as Text - Help - by El Forum - 08-08-2011, 04:20 AM
HTML email sending as Text - Help - by El Forum - 08-08-2011, 07:47 AM
HTML email sending as Text - Help - by El Forum - 08-08-2011, 08:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB