텍스트 대치 하다가 to, name 으로 한국어가 들어갔을 때 UTF-8로 인코딩 되지 않아 오류가 발생한 경우입니다.
{
"to": ["example@example.com", "example@example.com"]
, "sub": {
"%name%": ["테스트", "테테"]
}
}
A message was received from this address by our systems that had errors in the SMTPAPI header, and cannot be processed due to the following:
- invalid JSON
If you require assistance in working with the SendGrid API, please contact us at support@sendgrid.com
아래 구문으로 encodeText 처리하여 넘겨주면 정상적으로 메일 발송 성공을 확인할 수 있습니다.
message.addHeader("X-SMTPAPI", MimeUtility.encodeText(smtpJson));
Multipart multipart = new MimeMultipart("alternative");
BodyPart part = new MimeBodyPart();
message.addHeader("X-SMTPAPI", MimeUtility.encodeText(smtpJson));
part.setContent(content, "text/html; charset=utf-8");
multipart.addBodyPart(part);
message.setContent(multipart);
'개발자 > Sendgrid' 카테고리의 다른 글
[Sendgrid/intellij/JAVA] 메일 html 내 건별 텍스트 대치-Customizing your send (0) | 2021.05.21 |
---|---|
[Sendgrid/intellij/JAVA] unknown charset 'ms949' (0) | 2021.05.21 |
[Sendgrid/intellij/JAVA] JAVA SMTP 발송 소스 (0) | 2021.05.18 |
[Sendgrid/intellij/JAVA] API_KEY 발급 + JAVA 메일 발송 401, 403 오류 (0) | 2021.05.17 |