Skip to content
Browse files

Added the ability to do mail attachments as well as inline items

  • Loading branch information...
1 parent 45d285d commit 006a1efbe07659d90628082ed7d4d3598671e202 @dpp dpp committed Aug 14, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 core/util/src/main/scala/net/liftweb/util/Mailer.scala
View
6 core/util/src/main/scala/net/liftweb/util/Mailer.scala
@@ -43,7 +43,7 @@ trait Mailer extends SimpleInjector {
*/
final case class MessageHeader(name: String, value: String) extends MailTypes
abstract class MailBodyType extends MailTypes
- final case class PlusImageHolder(name: String, mimeType: String, bytes: Array[Byte])
+ final case class PlusImageHolder(name: String, mimeType: String, bytes: Array[Byte], attachment: Boolean = false)
/**
* Represents a text/plain mail body. The given text will
@@ -60,6 +60,7 @@ trait Mailer extends SimpleInjector {
final case class XHTMLMailBodyType(text: NodeSeq) extends MailBodyType
final case class XHTMLPlusImages(text: NodeSeq, items: PlusImageHolder*) extends MailBodyType
+
sealed abstract class RoutingType extends MailTypes
sealed abstract class AddressType extends RoutingType {
def address: String
@@ -283,6 +284,7 @@ trait Mailer extends SimpleInjector {
case PlainMailBodyType(txt) => bp.setText(txt, "UTF-8")
case PlainPlusBodyType(txt, charset) => bp.setText(txt, charset)
case XHTMLMailBodyType(html) => bp.setContent(encodeHtmlBodyPart(html), "text/html; charset=" + charSet)
+
case XHTMLPlusImages(html, img@_*) =>
val html_mp = new MimeMultipart("related")
val bp2 = new MimeBodyPart
@@ -293,7 +295,7 @@ trait Mailer extends SimpleInjector {
val rel_bpi = new MimeBodyPart
rel_bpi.setFileName(i.name)
rel_bpi.setContentID(i.name)
- rel_bpi.setDisposition("inline")
+ rel_bpi.setDisposition(if (!i.attachment) "inline" else "attachment")
rel_bpi.setDataHandler(new javax.activation.DataHandler(new javax.activation.DataSource {
def getContentType = i.mimeType

0 comments on commit 006a1ef

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