malformed email subject header when subject > 75 chars using codeigniter email lib

前端 未结 2 967
野的像风
野的像风 2021-01-19 15:43

I\'m getting some garble in my MIME headers when the subject is over 75 chars. When the line break is encoded in the header there is an extra line break that is invalid.

相关标签:
2条回答
  • 2021-01-19 16:28

    Since I myself had this exact problem I will share the solution here since the one shared does not work with version 2.2

    Find this piece of code located in system/libraries/Email.php:365

    public function subject($subject)
    {
        $subject = $this->_prep_q_encoding($subject);
        $this->_set_header('Subject', $subject);
        return $this;
    }
    

    With this one

    public function subject($subject)
    {
        $subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
        $this->_set_header('Subject', $subject);
        return $this;
    }
    
    0 讨论(0)
  • Apparently this is a known issue, caused by Subject lines > 75 chars.

    http://codeigniter.com/forums/viewthread/154493/P15/#925385

    The fix was to change the email config like this:

    $config['newline'] = "\r\n";
    $config['crlf']    = "\n"; 
    
    0 讨论(0)
提交回复
热议问题