com.openexchange.mail.mime.filler
Class MIMEMessageFiller

java.lang.Object
  extended by com.openexchange.mail.mime.filler.MIMEMessageFiller

public class MIMEMessageFiller
extends java.lang.Object

MIMEMessageFiller - Provides basic methods to fills an instance of MimeMessage with headers/contents given through an instance of ComposedMailMessage

Author:
Thorben Betten

Constructor Summary
MIMEMessageFiller(com.openexchange.session.Session session, com.openexchange.groupware.contexts.Context ctx)
          Initializes a new MIMEMessageFiller
MIMEMessageFiller(com.openexchange.session.Session session, com.openexchange.groupware.contexts.Context ctx, UserSettingMail usm)
          Initializes a new MIMEMessageFiller
 
Method Summary
 void deleteReferencedUploadFiles()
          Deletes referenced local uploaded files from session and disk after filled instance of MimeMessage is dispatched
 void fillMailBody(ComposedMailMessage mail, javax.mail.internet.MimeMessage mimeMessage, ComposeType type)
          Fills the body of given instance of MimeMessage with the contents specified through given instance of ComposedMailMessage.
 void setCommonHeaders(javax.mail.internet.MimeMessage mimeMessage)
          Sets common headers in given MIME message: X-Mailer and Organization.
 void setMessageHeaders(ComposedMailMessage mail, javax.mail.internet.MimeMessage mimeMessage)
          Sets necessary headers in specified MIME message: From/ Sender, To, Cc, Bcc, Reply-To, Subject, etc.
 void setReplyHeaders(MailMessage referencedMail, javax.mail.internet.MimeMessage mimeMessage)
          Sets the appropriate headers In-Reply-To and References in specified MIME message.
 void setSendHeaders(ComposedMailMessage mail, javax.mail.internet.MimeMessage mimeMessage)
          Sets the appropriate headers before message's transport: Reply-To, Date, and Subject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MIMEMessageFiller

public MIMEMessageFiller(com.openexchange.session.Session session,
                         com.openexchange.groupware.contexts.Context ctx)
Initializes a new MIMEMessageFiller

Parameters:
session - The session providing user data
ctx - The context

MIMEMessageFiller

public MIMEMessageFiller(com.openexchange.session.Session session,
                         com.openexchange.groupware.contexts.Context ctx,
                         UserSettingMail usm)
Initializes a new MIMEMessageFiller

Parameters:
session - The session providing user data
ctx - The context
usm - The user's mail settings
Method Detail

deleteReferencedUploadFiles

public void deleteReferencedUploadFiles()
Deletes referenced local uploaded files from session and disk after filled instance of MimeMessage is dispatched


setCommonHeaders

public void setCommonHeaders(javax.mail.internet.MimeMessage mimeMessage)
                      throws javax.mail.MessagingException
Sets common headers in given MIME message: X-Mailer and Organization.

Parameters:
mimeMessage - The MIME message
Throws:
javax.mail.MessagingException - If headers cannot be set

setMessageHeaders

public void setMessageHeaders(ComposedMailMessage mail,
                              javax.mail.internet.MimeMessage mimeMessage)
                       throws javax.mail.MessagingException,
                              MailException
Sets necessary headers in specified MIME message: From/ Sender, To, Cc, Bcc, Reply-To, Subject, etc.

Parameters:
mail - The composed mail
mimeMessage - The MIME message
Throws:
javax.mail.MessagingException - If headers cannot be set
MailException - If a mail error occurs

setReplyHeaders

public void setReplyHeaders(MailMessage referencedMail,
                            javax.mail.internet.MimeMessage mimeMessage)
                     throws javax.mail.MessagingException
Sets the appropriate headers In-Reply-To and References in specified MIME message.

Moreover the Reply-To header is set.

Parameters:
referencedMail - The referenced mail
mimeMessage - The MIME message
Throws:
javax.mail.MessagingException - If setting the reply headers fails

setSendHeaders

public void setSendHeaders(ComposedMailMessage mail,
                           javax.mail.internet.MimeMessage mimeMessage)
                    throws MailException
Sets the appropriate headers before message's transport: Reply-To, Date, and Subject

Parameters:
mail - The source mail
mimeMessage - The MIME message
Throws:
MailException - If a mail error occurs

fillMailBody

public void fillMailBody(ComposedMailMessage mail,
                         javax.mail.internet.MimeMessage mimeMessage,
                         ComposeType type)
                  throws javax.mail.MessagingException,
                         MailException,
                         java.io.IOException
Fills the body of given instance of MimeMessage with the contents specified through given instance of ComposedMailMessage.

Parameters:
mail - The source composed mail
mimeMessage - The MIME message to fill
type - The compose type
Throws:
javax.mail.MessagingException - If a messaging error occurs
MailException - If a mail error occurs
java.io.IOException - If an I/O error occurs