2525import org .apache .http .impl .client .HttpClientBuilder ;
2626import org .apache .http .impl .client .CloseableHttpClient ;
2727import org .apache .http .util .EntityUtils ;
28-
28+ import org . apache . http . entity . ContentType ;
2929
3030public class SendGrid {
3131 private static final String VERSION = "1.1.0" ;
@@ -88,7 +88,7 @@ public HttpEntity buildBody(Email email) {
8888 builder .addTextBody (String .format (PARAM_TO , i ), email .getTos ()[i ]);
8989
9090 for (int i = 0 , len = email .getToNames ().length ; i < len ; i ++)
91- builder .addTextBody (String .format (PARAM_TONAME , i ), email .getToNames ()[i ]);
91+ builder .addTextBody (String .format (PARAM_TONAME , i ), email .getToNames ()[i ], ContentType . create ( "text/plain" , "UTF-8" ) );
9292
9393 for (int i = 0 , len = email .getBccs ().length ; i < len ; i ++)
9494 builder .addTextBody (String .format (PARAM_BCC , i ), email .getBccs ()[i ]);
@@ -108,19 +108,19 @@ public HttpEntity buildBody(Email email) {
108108 builder .addTextBody (PARAM_FROM , email .getFrom ());
109109
110110 if (email .getFromName () != null && !email .getFromName ().isEmpty ())
111- builder .addTextBody (PARAM_FROMNAME , email .getFromName ());
111+ builder .addTextBody (PARAM_FROMNAME , email .getFromName (), ContentType . create ( "text/plain" , "UTF-8" ) );
112112
113113 if (email .getReplyTo () != null && !email .getReplyTo ().isEmpty ())
114114 builder .addTextBody (PARAM_REPLYTO , email .getReplyTo ());
115115
116116 if (email .getSubject () != null && !email .getSubject ().isEmpty ())
117- builder .addTextBody (PARAM_SUBJECT , email .getSubject ());
117+ builder .addTextBody (PARAM_SUBJECT , email .getSubject (), ContentType . create ( "text/plain" , "UTF-8" ) );
118118
119119 if (email .getHtml () != null && !email .getHtml ().isEmpty ())
120- builder .addTextBody (PARAM_HTML , email .getHtml ());
120+ builder .addTextBody (PARAM_HTML , email .getHtml (), ContentType . create ( "text/plain" , "UTF-8" ) );
121121
122122 if (email .getText () != null && !email .getText ().isEmpty ())
123- builder .addTextBody (PARAM_TEXT , email .getText ());
123+ builder .addTextBody (PARAM_TEXT , email .getText (), ContentType . create ( "text/plain" , "UTF-8" ) );
124124
125125 if (!email .getSMTPAPI ().jsonString ().equals ("{}" )) {
126126 builder .addTextBody (PARAM_XSMTPAPI , email .getSMTPAPI ().jsonString ());
@@ -388,4 +388,4 @@ public String getMessage() {
388388 return this .message ;
389389 }
390390 }
391- }
391+ }
0 commit comments