Welcome Guest, Not a member yet? Register   Sign In
email class config does not work

[eluser]Kenneth Allen[/eluser]
I was having a problem sending email in that I was sending the message as HTML but it was being received as text.

I had created an application/config/email.php file that contained the following, but the message was still being received as text.
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['useragent']        = 'CodeIgniter';        
$config['protocol']         = 'mail';        
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = '';
$config['smtp_user']        = '';
$config['smtp_pass']        = '';
$config['smtp_port']        = 25;
$config['smtp_timeout']     = 5;
$config['wordwrap']         = TRUE;
$config['wrapchars']        = 76;
$config['mailtype']         = 'html';
$config['charset']          = 'utf-8';
$config['validate']         = FALSE;
$config['priority']         = 3;
$config['crlf']             = "\r\n";
$config['newline']          = "\r\n";
$config['bcc_batch_mode']   = FALSE;
$config['bcc_batch_size']   = 200;

When I debugged the application and stepped into the first mail method call after the library load, the mail type was still 'text'! It seems that autoload is not properly processing the config file. I did step through the code and saw where the email config file was being included, but it did not seem to get processed to set the value in the email class instance.

I was finally able to resolve the issue by removing the email library from the autoload and manually loading it using the following code. Since this was the only value I wished to override, that was OK, but I would have preferred to have it auto loaded.
$config = array( 'mailtype' => 'html' );
$this->ci->load->library('email', $config);

Is this a bug in the email library load logic, or am I missing something? The documentation indicates that creating the config file as I did should work, but my runtime evaluations indicate this is not the case.

I've been uing:

$emailConfigs['mailtype'] = TRUE;

Which gives me HTML email output.

I recently extended the core email class and got this issue due to not passing $config through the constructor parameters. Maybe you did the same?

Theme © iAndrew 2016 - Forum software by © MyBB