Skip to content

feat: Add rawJsonString() - #10

Merged
eddiezane merged 1 commit into
sendgrid:masterfrom
awwa:master
May 15, 2015
Merged

feat: Add rawJsonString()#10
eddiezane merged 1 commit into
sendgrid:masterfrom
awwa:master

Conversation

@awwa

@awwa awwa commented May 15, 2015

Copy link
Copy Markdown
Contributor

When I use smtpapi-java with JavaMail, it is better to handle unescaped JSON string, because JavaMail has ability to fold and encode the custom headers.
If the x-smtpapi header is longer than 1000 characters, we have to fold it(add line break per 1000 characters).
http://docs.oracle.com/javaee/6/api/javax/mail/internet/MimeUtility.html#encodeText(java.lang.String)
http://docs.oracle.com/javaee/6/api/javax/mail/internet/MimeUtility.html#fold(int, java.lang.String)

@awwa

awwa commented May 15, 2015

Copy link
Copy Markdown
Contributor Author

The usage for new method will be like this:

SMTPAPI smtpapi = new SMTPAPI();
smtpapi.setTos(tos);
smtpapi.addSubstitutions("name", names);
smtpapi.addCategory("category1");

MimeMessage message = new MimeMessage(mailSession);
message.setHeader(
      "X-SMTPAPI",
      MimeUtility.fold(76, MimeUtility.encodeText(smtpapi.rawJsonString()))
);

eddiezane added a commit that referenced this pull request May 15, 2015
@eddiezane
eddiezane merged commit 1865e10 into sendgrid:master May 15, 2015
@eddiezane

Copy link
Copy Markdown
Contributor

Thanks @awwa! You're the man as usual buddy!

@awwa

awwa commented May 15, 2015

Copy link
Copy Markdown
Contributor Author

@eddiezane ULTRA FAST! Thank you so much!!!

@eshanholtz eshanholtz changed the title Add rawJsonString() feat: Add rawJsonString() Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants