Home > Java > JavaBase > body text

Java email garbled solution

Release: 2019-12-21 16:20:56
Original
2263 people have browsed it

Java email garbled solution

java solution for sending garbled emails:

//设置邮件主题  
message.setSubject(MimeUtility.encodeText(mail_subject,MimeUtility.mimeCharset("gb2312"), null));  
message.setContent(sendmessage, "text/html;charset=gbk"); // 设置邮件格式  
message.setSentDate(new Date()); // 设置邮件发送日期  
//设置邮件发件人名称  
Address address = new InternetAddress(usernames, MimeUtility.encodeText(personalName,MimeUtility.mimeCharset("gb2312"), null));
Copy after login

When a piece of Text or HTML is sent via email, the sent content first passes through a specified character The encoding is converted into a "byte string", and then the "byte string" is converted through a specified transfer encoding (Content-Transfer-Encoding) to obtain another string of "byte strings".

The title of the email uses a shorter format to mark "Character Encoding" and "Transfer Encoding".

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of Java email garbled solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!