CodeIgniter SMTP email message - characters replaced with equal signs

混江龙づ霸主 提交于 2019-12-18 03:24:24

问题


I'm using the CodeIgniter email library to send emails using our Exchange server. The problem I get is that the content of the email gets messed up.

There are some words that get replaced with equal signs "=", I tried 2 different Exchange servers (they are in different locations and have no relation what so ever) and I still get the same issue. If I use any other server as an SMTP server to send emails everything works fine and the content stays intact and unchanged.

Content before sending:

Dear Customer

Please find attached a comprehensive explanation of how to get our brochure of Angola. This has been sent to you at the request of Alex.

The information has been taken from www.example.co.uk  "Company name" is one of the leading tile and marble companies in the UK. 

Content after sending it through the Microsoft Exchange:

Dear Customer

Please find attached a comprehensive explanation of how to get our brochure of A=gola. This has been sent to you at the request of Alex.

The information has been taken from www.example.co.uk  "Company name" is one of the leadi=g tile and marble companies in the UK. 

As you can see for some reason some of the "n" characters were replaced with equal signs "=" (Example: Angola > A=gola)

My email configuration:

$this->load->library('email');
$config['charset']      = 'utf-8';
$config['mailtype']     = 'html';


// SMTP
$config['protocol']     = 'smtp';
$config['smtp_host']    = 'exchange.example.com'; //ssl://
$config['smtp_user']    = 'email@example.com';
$config['smtp_pass']    = 'password';
$config['smtp_port']    = 25;

$this->email->set_newline( "\r\n" );

$this->email->initialize( $config );

$this->email->clear();

......

$this->email->from( $frome, $fromn );
$this->email->to( $email );

$this->email->subject( $subject );
$this->email->message( $send_message );


$this->email->send();

Does anyone know why is the Microsoft exchange behaving this way? or is there some sort of setting I should use?


回答1:


That's odd, specially since not all the ns are transliterated and not at a specific position.

Try calling $this->email->set_crlf( "\r\n" ); as well. Look up the message details in Exchange and inspect the Content-Type and Charset / Encoding - post the raw thing here so we can inspect it.

I found this in Microsoft Knowledgebase:

Microsoft Exchange uses an enhanced character set. The default MIME character set for Microsoft Exchange is ISO 8859-1. Some gateways do not support the way this character set issues a soft return for line feeds. When this occurs, each line is terminated with an equal sign showing the line break where the gateway's line-length support ends.




回答2:


I solved this (kinda) by setting $charlim = '998' in the _prep_quoted_printable function.

When I set $crlf = "\r\n" the resulting email was completely garbled for some reason. But I noticed that the = signs were appearing at regular intervals which was caused by the line length being limited to 76 characters. So increasing the max characters per line (998 is the RFC2822 limit) solves the problem, as long as you don't have really long lines.



来源:https://stackoverflow.com/questions/13065695/codeigniter-smtp-email-message-characters-replaced-with-equal-signs

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