Skip to content
Browse files

fixed subject enoding issue with non ASCI characters

  • Loading branch information...
1 parent 4f887b0 commit 379670c40cdbf3eec8f4a4d8dab8065ee8e53695 @lkuczera lkuczera committed Mar 20, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 core/util/src/main/scala/net/liftweb/util/Mailer.scala
View
4 core/util/src/main/scala/net/liftweb/util/Mailer.scala
@@ -224,15 +224,15 @@ trait Mailer extends SimpleInjector {
case Full(a) => jndiSession openOr Session.getInstance(buildProps, a)
case _ => jndiSession openOr Session.getInstance(buildProps)
}
-
+ val subj = MimeUtility.encodeText(subject.subject, "utf-8", "Q")
@indrajitr
Lift Web Framework member
indrajitr added a note Mar 22, 2012

Should we always force "UTF-8"?

How about using the alternative signature MimeUtility.encodeText(String) instead? This allows using the Sytem property mail.mime.charset with fallback to platform default. Alternately, you could use the value of Mailer.charSet.

@andreak
Lift Web Framework member
andreak added a note Mar 22, 2012

Definitly not enforce it.
Encoding of the subject should try the following:

  1. Take it from the inline-encoding (don't remember what this is called) Might be: Subject: =?utf-8?Q?SubjectTextHere or Subject: =?iso-8859-1?Q?SubjectTextHere
  2. Try the Content-Type header of the email
  3. Try mail.mime.charset System-property
  4. Use file.encoding system-property

Or what?

@lkuczera
Lift Web Framework member
lkuczera added a note Mar 22, 2012

I will switch that to, Mailer.charSet then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
val message = new MimeMessage(session)
message.setFrom(from)
message.setRecipients(Message.RecipientType.TO, info.flatMap {case x: To => Some[To](x) case _ => None})
message.setRecipients(Message.RecipientType.CC, info.flatMap {case x: CC => Some[CC](x) case _ => None})
message.setRecipients(Message.RecipientType.BCC, info.flatMap {case x: BCC => Some[BCC](x) case _ => None})
// message.setReplyTo(filter[MailTypes, ReplyTo](info, {case x @ ReplyTo(_) => Some(x); case _ => None}))
message.setReplyTo(info.flatMap {case x: ReplyTo => Some[ReplyTo](x) case _ => None})
- message.setSubject(subject.subject)
+ message.setSubject(subj)
@d6y
Lift Web Framework member
d6y added a note Mar 22, 2012

Apparently there's a variation on setSubject that takes a charset argument:

http://docs.oracle.com/javaee/1.4/api/javax/mail/internet/MimeMessage.html

I'm unsure what it does regarding Q or B encoding, but note it does place a restriction on us: "The application must ensure that the subject does not contain any line breaks."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
info.foreach {
case MessageHeader(name, value) => message.addHeader(name, value)
case _ =>

0 comments on commit 379670c

Please sign in to comment.
Something went wrong with that request. Please try again.