Welcome Guest, Not a member yet? Register   Sign In
mailtype option is ignored, but only when inside config file
#1

[eluser]sparky672[/eluser]
Case 1 - working

In Controller:

Code:
$this->load->library('email');
    
$config['newline']    = '\r\n';
$config['crlf']    = '\r\n';
$config['mailtype']    = 'text';
$this->email->initialize($config);

$this->email->from('[email protected]', 'my domain');
$this->email->to('[email protected]');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();

Output:

Code:
Line one.

Line two.

Line three.

Properly Rendered:

Code:
Line one.

Line two.

Line three.

------------

AS per the Email Class documentation:

"If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the 'email.php', add the $config array in that file. Then save the file at 'config/email.php' and it will be used automatically. You will NOT need to use the '$this->email->initialize()' function if you save your preferences in a config file."

------------

Case 2 - broken

In "config/email.php":

Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

$config['useragent']        = 'CodeIgniter TEST';  // to prove config file is working
$config['newline']    = "\r\n";
$config['crlf']    = "\r\n";
$config['mailtype']    = 'text';

In Controller:

Code:
$this->load->library('email');

// commented out lines moved to email.php config file  
// $config['newline']    = '\r\n';
// $config['crlf']    = '\r\n';
// $config['mailtype']    = 'text';
// $this->email->initialize($config);

$this->email->from('[email protected]', 'my domain');
$this->email->to('[email protected]');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();

Output:

Code:
This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_514f9c33db0fd
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Line one.

Line two.

Line three.

--B_ALT_514f9c33db0fd
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Line one.

Line two.

Line three.

--B_ALT_514f9c33db0fd--

Improperly Rendered:

Code:
Line one.Line two.Line three.

--------

Case #2 is broken. The "mailtype=text" option is totally ignored, and a multi-part MIME message is generated instead of only a plain text message as in Case #1.

The only difference between Case #1 and Case #2 is the external "email.php" config file. So why is the Case #2 output different?
#2

[eluser]sparky672[/eluser]
Never mind.

Entire problem is being caused by a setting inside my Ion Auth configuration file...

Code:
$config['email_config'] = array(
'mailtype' => 'html',
);





Theme © iAndrew 2016 - Forum software by © MyBB