svk
svk

Reputation: 4553

How to send an email in base64 encode in CodeIgniter?

I am facing the issue the odd exclamation symbol in email. For that I tested in seperate mail funation with base64 encode. Thats working fine. I set the header like this.

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "Content-Transfer-Encoding:base64" . "\r\n"; 
// More headers
$headers .= 'From:'.$from. "\r\n";
$htmlcode = rtrim(chunk_split(base64_encode($msg))); 
$ret=mail($to,$subj,$htmlcode,$headers);

Now I want to set the same header option in CodeIgniter. I tried with the option in configuration.

$_configure['_encoding']="base64";
$email= new Email($config);    

But it doesn't work. How can set the header like above in CodeIgniter?

Edit:

Currently using CodeIgniter Email class only.

Upvotes: 2

Views: 3474

Answers (2)

Yar
Yar

Reputation: 39

$config['_bit_depths'] = array('7bit', '8bit', 'base64');
$config['_encoding'] = 'base64';

Upvotes: 3

PaulM
PaulM

Reputation: 3269

You should extend the Email class to add this, it's pretty easy to do.

When you do, add a public function to _set_header as this generates the email header for you.

Not tested, but something like this:

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

class MY_Email extends CI_Email {

    public function __construct()
    {
        parent::__construct();
    }

    public function set_header($header, $value) {
        parent::_set_header($header, $value);
    }
}

then in your email code, something to the effect of:

set_header('_encoding', 'base64');

Upvotes: 0

Related Questions