Re: [2.0.x-java] Typesafe email plugin charset and header customizing?

428 views
Skip to first unread message

Poma

unread,
Oct 19, 2012, 7:48:45 AM10/19/12
to play-fr...@googlegroups.com
Any news on this issue? I'm having the same problem as well.

On Monday, August 20, 2012 8:41:58 PM UTC+4, 開発太郎 wrote:
Hello, I'm trying to send Japanese UTF8 email by using Typesafe Email plugin on Java play2.
I can send text emails successfully, however the charactor code are set as "charset=ANSI_X3.4-1968" on heroku server and cannot read them.
I can send Japanese "charset=ISO-2022-JP" emails successfully, from my developping Japanese OS server(LANG = ja_JP.UTF-8).
Anybody knows to fix this problem?

My program is like this.


String mailtitle = "Japanese title";
String mailbody = "Japanese mail body";

MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();
mail.setCharset("UTF-8");
mail.addHeader("Content-Transfer-Encoding", "7bit");
mail.setSubject(mailtitle);
mail.addRecipient("exa...@foo.com");
mail.addFrom("Example site <nor...@foo.com>");
mail.send( mailbody );

Thank you for your help in advance.

peter hausel

unread,
Oct 19, 2012, 7:00:27 PM10/19/12
to play-fr...@googlegroups.com


On Monday, August 20, 2012 12:41:58 PM UTC-4, 開発太郎 wrote:
Hello, I'm trying to send Japanese UTF8 email by using Typesafe Email plugin on Java play2.
I can send text emails successfully, however the charactor code are set as "charset=ANSI_X3.4-1968" on heroku server and cannot read them.
I can send Japanese "charset=ISO-2022-JP" emails successfully, from my developping Japanese OS server(LANG = ja_JP.UTF-8).
Anybody knows to fix this problem?

My program is like this.


String mailtitle = "Japanese title";
String mailbody = "Japanese mail body";

MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();
mail.setCharset("UTF-8");
mail.addHeader("Content-Transfer-Encoding", "7bit");
mail.setSubject(mailtitle);
mail.addRecipient("exa...@foo.com");
mail.addFrom("Example site <nor...@foo.com>");
mail.send( mailbody );

Thank you for your help in advance.
As far as I can tell this should work. Did you try to send emails from your dev machine using this code? if so - what was the charset?
this issue maybe related:
 
 

Andreas Fürer

unread,
Mar 5, 2013, 5:42:41 AM3/5/13
to play-fr...@googlegroups.com
I had exactly the same issue. It was working correctly in my dev environment, but not on my heroku deployment. I explicitly set the charset of the mailer plugin to "utf-8". That didn't help.

However, if you set the default file encoding on Heroku to UTF8 it works. You can do that as follows:
heroku config:add SBT_OPTS="-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF8"
heroku config:add JAVA_OPTS="-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF8"

@peter
After a quick look at the mailer plugin and Apache Commons srcs I have the following suspicion. The mailer plugin does the setCharset(..) after the text is set. I think the order is significant here. The Apache Commons MultiPartEmail sets the charset on the MultiPart *before* the mailer plugin sets it to UTF-8. So, a default charset might be deduced here. Just a guess, I did not verify it.

Nilanjan Raychaudhuri

unread,
Mar 5, 2013, 11:42:20 AM3/5/13
to play-fr...@googlegroups.com
Could you please raise a github issue for this one. I will investigate.

Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri

Matthias Kurz

unread,
Oct 23, 2014, 6:38:09 PM10/23/14
to play-fr...@googlegroups.com
The just released mailer version 2.3.1 includes a charset fix (https://github.com/typesafehub/play-plugins/pull/131). Maybe this fix solves your problems. Could you upgrade to this latest mailer version and let us know? BTW: The issue for your problem is https://github.com/typesafehub/play-plugins/issues/66
Reply all
Reply to author
Forward
0 new messages