Email subject encoding problem (solved but...)

3,933 views
Skip to first unread message

Jakub Czuchnowski

unread,
Mar 15, 2012, 1:35:28 PM3/15/12
to lif...@googlegroups.com
Hi,

It occured to me today that the mail subject's encoding is platform
dependent (better late than never).
The problem appeared when I deployed my app on Linux server. On
Windows I got email message with header:
Subject: =?Cp1250?Q?=AF=B9danie_ponownego_ustawienia_has=B3a?=

but on Linux it was:
Subject: =?ANSI_X3.4-1968?Q?=3F=3Fdanie_ponownego_ustawienia_has=3Fa?=

and since there were Polish letters in there, I got ?? symbols instead
of the letters.
Obviously the solution was to add -Dfile.encoding=UTF8 to the web
server startup. But I was wondering, shouldn't Lift provide some
default? Maybe with mail.mime.charset system property?

Jakub

Kajo Marton

unread,
Mar 15, 2012, 2:10:21 PM3/15/12
to lif...@googlegroups.com
Do you use Lift's Mailer?

if yes, try this:

Mailer.sendMail(From(from), Subject(MimeUtility.encodeText(subject,"utf-8",null)), To(user.email.is), XHTMLMailBodyType(bodyHtml) )

with this you can set subject charset.

--
Kajo Marton
Bratislava, Slovakia

Dňa štvrtok, 15. marca 2012 18:35:28 UTC+1 Jakub Czuchnowski napísal(-a):

Jakub Czuchnowski

unread,
Mar 15, 2012, 7:28:31 PM3/15/12
to lif...@googlegroups.com
Thanks. Yes, I'm using Mailer. Good to know about this solution,
although I think I'll stay with my -Dfile.encoding=UTF8 solution at
this point.

--
Jakub

2012/3/15 Kajo Marton <kajo....@gmail.com>:

> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code

David Pollak

unread,
Mar 16, 2012, 2:55:02 AM3/16/12
to lif...@googlegroups.com
This issue just came up in the context of HTTP headers.  Please open a ticket at http://ticket.liftweb.net and I'll make sure the characters for Mailer are UTF-8 encoded.


Jakub

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


Jakub Czuchnowski

unread,
Mar 16, 2012, 11:43:58 AM3/16/12
to lif...@googlegroups.com
Created Issue #1242
Thanks.

--
Jakub

David Pollak

unread,
Mar 16, 2012, 11:46:09 AM3/16/12
to lif...@googlegroups.com


On Fri, Mar 16, 2012 at 3:43 PM, Jakub Czuchnowski <jakub.cz...@gmail.com> wrote:
Created Issue #1242
Thanks.

Thank you!

Lukasz Kuczera

unread,
Mar 16, 2012, 11:46:59 AM3/16/12
to lif...@googlegroups.com
You can fix that by encoding text explicitly. 

object Mailer extends net.liftweb.util.Mailer {

  override def sendMail(from: From, subject: Subject, rest: MailTypes*) {
    val subj = MimeUtility.encodeText(subject.subject, "utf-8", "Q")
    super.sendMail(from, Subject(subj), rest:_*)
  }
}


I can work on fixing that ticket.

David Pollak

unread,
Mar 16, 2012, 11:51:06 AM3/16/12
to lif...@googlegroups.com
Awesome


--

Lukasz Kuczera

unread,
Mar 19, 2012, 2:37:45 AM3/19/12
to lif...@googlegroups.com
I can't see issue #1242 am I missing something ?


On Thursday, March 15, 2012 6:35:28 PM UTC+1, Jakub Czuchnowski wrote:

Lukasz Kuczera

unread,
Mar 19, 2012, 2:55:06 AM3/19/12
to lif...@googlegroups.com
Gosh we moved to github :]
Reply all
Reply to author
Forward
0 new messages