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

[eluser]ericbae[/eluser]
Hello,

I've searched the forum but couldn't find a straight answer to this.

I am sending HTML email, but I am not getting it as HTML email. It includes all the tags as content of the email.

i.e. <html><body>email content</body></html>

any ideas? I've configured the email.php so that it sends HTML email.

thanks in advance.
#2

[eluser]sophistry[/eluser]
post code
#3

[eluser]ericbae[/eluser]
Here is my code...

Code:
$this->load->library('email');
$this->email->from('[email protected]', 'aaa');
$this->email->to($email);
$this->email->subject('test');
$message = "<html><body>" .
       "<p>test email</p>" .
       "&lt;/body&gt;&lt;/html&gt;";
                  
$this->email->message($message);
$this->email->send();

and the config file

&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'mail';
$config['smtp_host'] = 'mail.aaa.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'aaa';
$config['mailtype'] = 'html';

?&gt;
#4

[eluser]sophistry[/eluser]
i don't see anything immediately wrong with that - it should work.

here are a few things to try:
Code:
echo $this->email->print_debugger();

that will show you if anything goes wrong at the server. probably not it, but it is instructive.

next, what does the raw email look like when you get it in your email client (do view source, or view original to see the actual raw text). there should be a MIME section in there that defines the message (part) as text/html. it would help if you have a sample of that text to post, but if you know what a MIME section in a raw email looks like then just qualify that it is there when you get the message.

try a different smtp sender if you can

try a different mail client.

let us know how it goes.
#5

[eluser]mihu[/eluser]
Code:
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);

This works to me.
#6

[eluser]gurthgor[/eluser]
It happens the same to me, just plain text, there are no errors. I tried sending a message to my mail using thunderbird and to a gmail account and just plain text.
It seems ignore the mailtype and just go for plain text
When i try to use gmail as mail server to redirect it just loads forever and doesnt show anything.
#7

[eluser]drewbee[/eluser]
Hi Gentlemen. I just had the same issue and posted a bug over for it. When using a configuration file, the configuration file needs to start with a capital E ex. Email.php. The documentation needs to be updated for this.
#8

[eluser]fchristant[/eluser]
drewbee,

Thanks, that fixed it for me!
#9

[eluser]Dr. Seuss[/eluser]
It does not appear to have fixed it for me....

Code:
this->load->library('email');
$this->email->from('[email protected]', 'Website');
$this->email->to($eml);
$this->email->subject($strSubject);
$this->email->message("&lt;html&gt;&lt;body>".$strMessage."&lt;/body&gt;&lt;/html>");
$this->email->send();

My config file:

Code:
$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";

The email is sent, but it displays as plain text, not html.

My config file is named "Email.php".

This is not the first time that I have searched for a solution to this, but this time I must search until I find one. All help and suggestions are appreciated.
#10

[eluser]sophistry[/eluser]
what version of CI? there were some recent fixes to email functionality... also, at least one that is still in SVN version.

make sure you are setting all the variables you think you are.

also, post resulting email and all relevant code. it's pretty near impossible to give feedback without ascertaining that everything else is shipshape.




Theme © iAndrew 2016 - Forum software by © MyBB