- Function EncodeHeader ($ str, $ position = 'text', $ pl = 0 ){
- If ($ pl) return "=? ". $ This-> CharSet ."? B? ". Base64_encode ($ str )."? = ";
A parameter that is defined for this function. Naturally, you need to modify the parameters of all the places where this function is called. Search: EncodeHeader (you need to modify all the following methods:
- $ Result. = $ this-> HeaderLine ("Subject", $ this-> EncodeHeader (trim ($ this-> Subject )));
-
Changed:
- $ Result. = $ this-> HeaderLine ("Subject", $ this-> EncodeHeader (trim ($ this-> Subject), 'text', 1 ));
The third reference is defined as 1, so that we can call the judgment statement in the function we changed. Now, remember to set CharSet = UTF8 when calling this class. In this way, this judgment statement can be converted to UTF8 without garbled characters. It can be written as follows:
- $ Mail = new PHPMailer ();
- $ Mail-> CharSet = "utf8 ";
Second, fix the garbled email Title. Subject is the title of the processed Email. you need to find this location. It's called like mine.
- $ Mail = new PHPMailer ();
- $ Mail-> Subject = "XX title ";
In this case, change it to the following:
- $ Mail-> Subject = "=? UTF-8? B? ". Base64_encode (" XX title ")."? = ";
-
It's also transcoding. Third: the basic principle of Fixing garbled characters in other places is the same as that of the second solution. FromName is used to process the sender. Find the sender's name: I wrote it like this:
- $ Mail = new PHPMailer ();
- $ Mail-> FromName = "=? UTF-8? B? ". Base64_encode (" yellow card online customer message ]")."? = ";
If you can solve the above three problems, Phpmailer can basically solve the garbled problem when sending a Chinese email. Appendix: an example code for modifying the complete phpmailer email sending: http://file.jbxue.com/code/201304/phpmailer_lyb_jbxue.com.zip. |