Welcome Guest, Not a member yet? Register   Sign In
HTML Email not displaying as HTML but as text
#11

[eluser]Dr. Seuss[/eluser]
Certainly, my apologies.

I am using CI 1.7.1.

Here is the complete function:

Code:
function _authmail($eml, $strSubject,$strMessage ){
$this->load->library('email');

// $this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Website');
$this->email->to($eml);
$this->email->subject($strSubject);
$this->email->message($strMessage);
$this->email->send();

// echo $this->email->print_debugger();

}

...and the config file, "Email.php":
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
*/

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'password';
$config['smtp_timeout'] = 30;
$config['email']['mailtype']  = 'html';
$config['email']['charset']   = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";

And the resulting email:

Quote: Thu, 14 May 2009 11:44:45 -0700 (PDT)
User-Agent: CodeIgniter
Date: Thu, 14 May 2009 18:44:44 +0000
From: "Website" <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?utf-8?Q?Please_Validate_Account_Creation?=
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

&lt;html&gt;&lt;body>You have requested the creation of an account on the
website. Please click <a
href='validate/A8B3B65678FFF04BE65141281FE0FE23B51E8762FA4A0994F6217AE0771C
44EC610CA78CFBD2D7F2797B41B7BB5DFCF4'>here</a>
or copy-and-paste the following link into your borowser's adress bar.

http://dx.website.com/validate/A8B3B6567...B7BB5DFCF4

&lt;/body&gt;&lt;/html>

I note that the line "Content-Type: text/plain; charset=utf-8" and I don't know if that is the problem or not (i.e. my '$config['email']['mailtype'] = 'html'" is not having intended effect).

Thanks for the scrutiny.
#12

[eluser]TheFuzzy0ne[/eluser]
Sorry if I'm missing something obvious here, but why the:

Code:
$config['email']['mailtype']  = 'html';
$config['email']['charset']   = 'utf-8';

and not

Code:
$config['mailtype']  = 'html';
$config['charset']   = 'utf-8';

as written in the user guide?
#13

[eluser]Dr. Seuss[/eluser]
Duh. That fixed it. Thank you ever so much.

I think I copied-and-pasted those lines from some example long ago and just assumed that they MUST be correct--and never bothered to compare against the user guide.

Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB