pt.digitalis.dif.utils.mail
Class MailSender

java.lang.Object
  extended by pt.digitalis.dif.utils.mail.MailSender

public class MailSender
extends Object

The Class MailSender.

Author:
Pedro Viegas pviegas@digitalis.pt
Created on:
Feb 28, 2009

Field Summary
protected static MailSender instance
          The MailSender singleton instance
 
Constructor Summary
MailSender(IMailConfiguration configuration)
          MailSender Constructor
 
Method Summary
 IMailConfiguration getConfiguration()
          Inspector for the 'configuration' attribute.
static MailSender getInstance()
          Inspector for the 'instance' attribute.
 boolean sendEmail(MailType type, String from, String to, String cc, String bcc, String subject, String body, List<String> attachments, Map<String,String> images)
          Send an email.
 boolean sendEmail(MailType type, String from, String to, String cc, String bcc, String subject, String body, List<String> attachments, Map<String,String> images, boolean disableErrorLog)
          Send an email.
 boolean sendHTMLEmail(String to, String cc, String bcc, String subject, String body)
          Send an HTML text email.
 boolean sendHTMLEmail(String to, String cc, String bcc, String subject, String body, List<String> attachments, Map<String,String> images)
          Send an HTML text email.
 boolean sendHTMLEmail(String to, String cc, String bcc, String subject, String body, String attachments, String images)
          Send an HTML text email.
 boolean sendHTMLEmailWithAttachements(String to, String cc, String bcc, String subject, String body, List<String> attachments)
          Send an HTML text email.
 boolean sendHTMLEmailWithAttachements(String to, String cc, String bcc, String subject, String body, String attachments)
          Send an HTML text email.
 boolean sendHTMLEmailWithImages(String to, String cc, String bcc, String subject, String body, Map<String,String> images)
          Send an HTML text email.
 boolean sendHTMLEmailWithImages(String to, String cc, String bcc, String subject, String body, String images)
          Send an HTML text email.
 boolean sendTextEmail(String to, String cc, String bcc, String subject, String body)
          Send a plain text email.
 boolean sendTextEmail(String to, String cc, String bcc, String subject, String body, List<String> attachments)
          Send a plain text email.
 boolean sendTextEmail(String to, String cc, String bcc, String subject, String body, String attachments)
          Send a plain text email.
static void setInstance(MailSender instance)
          Modifier for the 'instance' attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static MailSender instance
The MailSender singleton instance

Constructor Detail

MailSender

public MailSender(IMailConfiguration configuration)
MailSender Constructor

Parameters:
configuration - the IMailConfiguration
Method Detail

getInstance

public static MailSender getInstance()
Inspector for the 'instance' attribute.

Returns:
the instance value

setInstance

public static void setInstance(MailSender instance)
Modifier for the 'instance' attribute.

Parameters:
instance - the new instance value to set

getConfiguration

public IMailConfiguration getConfiguration()
Inspector for the 'configuration' attribute.

Returns:
the configuration value

sendEmail

public boolean sendEmail(MailType type,
                         String from,
                         String to,
                         String cc,
                         String bcc,
                         String subject,
                         String body,
                         List<String> attachments,
                         Map<String,String> images)
                  throws javax.mail.internet.AddressException,
                         javax.mail.MessagingException
Send an email.

Parameters:
type - the mail type
from - the sender address
to - the mail destination address field.
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths.
images - the html embedded images. Names will be server paths.
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendEmail

public boolean sendEmail(MailType type,
                         String from,
                         String to,
                         String cc,
                         String bcc,
                         String subject,
                         String body,
                         List<String> attachments,
                         Map<String,String> images,
                         boolean disableErrorLog)
                  throws javax.mail.MessagingException
Send an email.

Parameters:
type - the mail type
from - the sender address
to - the mail destination address field.
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths.
images - the html embedded images. Names will be server paths.
disableErrorLog -
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmail

public boolean sendHTMLEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmail

public boolean sendHTMLEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body,
                             List<String> attachments,
                             Map<String,String> images)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths.
images - the html embedded images. Names will be server paths.
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmail

public boolean sendHTMLEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body,
                             String attachments,
                             String images)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths and list should be comma separated
images - the html embedded images. Names will be server paths. Format is: "id=imagePath,id2=imagePath"
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmailWithAttachements

public boolean sendHTMLEmailWithAttachements(String to,
                                             String cc,
                                             String bcc,
                                             String subject,
                                             String body,
                                             List<String> attachments)
                                      throws javax.mail.internet.AddressException,
                                             javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths.
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmailWithAttachements

public boolean sendHTMLEmailWithAttachements(String to,
                                             String cc,
                                             String bcc,
                                             String subject,
                                             String body,
                                             String attachments)
                                      throws javax.mail.internet.AddressException,
                                             javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
attachments - the mail attachments. Names will be server paths and list should be comma separated
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmailWithImages

public boolean sendHTMLEmailWithImages(String to,
                                       String cc,
                                       String bcc,
                                       String subject,
                                       String body,
                                       Map<String,String> images)
                                throws javax.mail.internet.AddressException,
                                       javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
images - the html embedded images. Names will be server paths.
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendHTMLEmailWithImages

public boolean sendHTMLEmailWithImages(String to,
                                       String cc,
                                       String bcc,
                                       String subject,
                                       String body,
                                       String images)
                                throws javax.mail.internet.AddressException,
                                       javax.mail.MessagingException
Send an HTML text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in HTML
images - the html embedded images. Names will be server paths. Format is: "id=imagePath,id2=imagePath"
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendTextEmail

public boolean sendTextEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send a plain text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in plain text
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendTextEmail

public boolean sendTextEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body,
                             List<String> attachments)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send a plain text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in plain text
attachments - the mail attachments. Names will be server paths.
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email

sendTextEmail

public boolean sendTextEmail(String to,
                             String cc,
                             String bcc,
                             String subject,
                             String body,
                             String attachments)
                      throws javax.mail.internet.AddressException,
                             javax.mail.MessagingException
Send a plain text email.

Parameters:
to - the mail destination address field
cc - the mail CC address field.
bcc - the mail BCC address field.
subject - the mail subject
body - the mail body, in plain text
attachments - the mail attachments. Names will be server paths and list should be comma separated
Returns:
T if the mail was sent successfully. F otherwise
Throws:
javax.mail.internet.AddressException - when an address is invalid
javax.mail.MessagingException - when an error occurs when sending the email


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.