A case of message header garbled problem solving

Source: Internet
Author: User

Recently there is user feedback under Mac through airmail, Outlook and so on mail client view system The title of the message is displayed as garbled, but under Windows normal.

Saved as eml via mail client, opened with sublime Text 2, can be found to show the following effects:

date:wed, 19:54:57 +0800from: < omit >to here: "=? GBK? B?zt6+za==?= "< omitted >subject here: [Mtlñð ¢Ö§³Å]ÏÎÄ¿X´Ì¬Í¨ÖªX-MAILER:SMTP-CLI 3.6, see/HTTP Smtp-cli.logix.czmessage-id: [Email protected]

Subject the Chinese content directly, and does not conform to the Mail MIME specification. Windows appears normal, but only because the system itself is well-compatible.

To encode the appropriate text, simply follow the following format:

=?charset?encoding?encoded text?=

The encoding has two optional values: Q and B, which represent the QP encoding (quoted-printable), which is BASE64 encoded.

We chose BASE64 as the coding scheme to deal with subject:

Private string Encodesubject (string subject) {        byte[] base64 =  Org.apache.commons.codec.binary.Base64.encodeBase64 (Subject.getbytes ());         return New String (base64));    }

After such processing, sent out of the mail subject is no longer Chinese, garbled problem will be solved.

Resources

Https://en.wikipedia.org/wiki/MIME

A case of message header garbled problem solving

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.