Invalid email subject title for subject> 75 characters using codeigniter email lib

I get some distortion in the MIME headers when the subject is over 75 characters. When a line break is encoded in the header, there is an additional line break that is not valid.

Some mail gateways bounce e-mail using the "Canceled MIME field :? = =? Utf-8? Q? SUBJECT? =" .

Does anyone have any experience with utf-8 issues sending emails using CodeIgniter?


-snip- Return-Path: *** Subject: =?utf-8?Q?SUBJECT_LINE <-- ?= <-- Problem in Subject header =?utf-8?Q?SUBECT_LINE_2?= <-- To: *** Reply-To: *** -snip- 

Update: This has nothing to do with gmail smtp. I rewrote the question in the hope that it will help someone in the future.

+4
source share
2 answers

This seems to be a known issue caused by the Subject string> 75 characters.

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

The fix was to change the email configuration as follows:

 $config['newline'] = "\r\n"; $config['crlf'] = "\n"; 
+15
source

Since I had this exact problem, I will share the solution here, since the proposed solution does not work with version 2.2

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

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

With the help of this

 public function subject($subject) { $subject = '=?UTF-8?B?'.base64_encode($subject).'?='; $this->_set_header('Subject', $subject); return $this; } 
+2
source

Source: https://habr.com/ru/post/1384241/


All Articles