KEYCLOAK-3089 Change email subject encoding to utf-8/base64

This commit is contained in:
Некрасов Александр Сергеевич 2016-06-07 09:11:46 +06:00
parent b2d8c6bca2
commit 5474496867

View file

@ -33,6 +33,7 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -111,7 +112,8 @@ public class DefaultEmailSenderProvider implements EmailSenderProvider {
Message msg = new MimeMessage(session); Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from)); msg.setFrom(new InternetAddress(from));
msg.setHeader("To", address); msg.setHeader("To", address);
msg.setSubject(subject); msg.setSubject(MimeUtility.encodeText(subject, "utf-8", "B"));
msg.setContent(multipart); msg.setContent(multipart);
msg.saveChanges(); msg.saveChanges();
msg.setSentDate(new Date()); msg.setSentDate(new Date());