From 04db511351db70ea603cb65f3f2c5c0b7462d9cc Mon Sep 17 00:00:00 2001 From: Chris Jaekl Date: Sun, 13 Dec 2015 14:15:34 +0900 Subject: [PATCH] DM_DEFAULT_ENCODING: Be explicit that we're using 7-bit ASCII when sending email. --- prod/net/jaekl/qd/util/SendMail.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prod/net/jaekl/qd/util/SendMail.java b/prod/net/jaekl/qd/util/SendMail.java index b4c7834..33be358 100644 --- a/prod/net/jaekl/qd/util/SendMail.java +++ b/prod/net/jaekl/qd/util/SendMail.java @@ -3,11 +3,13 @@ package net.jaekl.qd.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -66,7 +68,7 @@ public class SendMail { { try ( Socket sock = openSocket(m_smtpHost, m_smtpPort); - PrintWriter pw = new PrintWriter(sock.getOutputStream(), true); + PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream(), StandardCharsets.US_ASCII), true); BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream(), getCharset())); ) { -- 2.39.2