How to send an email in base64 encode in CodeIgniter?

我只是一个虾纸丫 提交于 2019-12-11 02:49:27

问题


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.


回答1:


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



回答2:


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');



来源:https://stackoverflow.com/questions/7804198/how-to-send-an-email-in-base64-encode-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!