Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed subject enoding issue with non ASCI characters

  • Loading branch information...
commit 379670c40cdbf3eec8f4a4d8dab8065ee8e53695 1 parent 4f887b0
@lkuczera lkuczera authored
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,7 +224,7 @@ 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 Owner

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 Owner
andreak added a note

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 Collaborator

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})
@@ -232,7 +232,7 @@ trait Mailer extends SimpleInjector {
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 Owner
d6y added a note

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 _ =>
@indrajitr

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

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

I will switch that to, Mailer.charSet then.

@d6y

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."

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