public abstract class AbstractMailer extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractMailer.Configuration
Generic mailer configurations
|
| Constructor and Description |
|---|
AbstractMailer() |
| Modifier and Type | Method and Description |
|---|---|
static void |
configure(InputStream input)
Loads mailer properties from a given configuration file input stream
|
static void |
configure(Properties properties) |
protected static Collection<javax.mail.internet.InternetAddress> |
convertStringsToAddressess(Collection<String> mails)
Converts a list of strings to a list of corresponding internet addresses
|
protected static javax.mail.internet.InternetAddress |
convertStringToAddress(String mail)
Converts a given string representation of an email address to an internet address
|
protected static Properties |
getConfiguration()
Gets the Properties object with the mailer configurations.
|
protected static String |
getConfigurationProperty(String key)
Gets the configuration property for the given key
|
protected static String |
getConfigurationProperty(String key,
String defaultValue)
Gets the configuration property for the given key
|
String |
getDebugAddress()
Returns the debug mode email address.
|
static List<String> |
getList(String value)
Helper function to get a list from a configuration property value
|
boolean |
isDebug()
Returns whether or not the mailer is in debug mode
|
protected static boolean |
isValidBasicConfiguration(Properties config)
Checks if any essential configurations are incorrect
|
protected boolean |
isValidConfiguration(Properties config)
Checks if the mailer configurations are all correct
|
static boolean |
isValidEmail(String email)
Helper function to aid in the validation of email addresses.
|
protected abstract boolean |
isValidMailerConfiguration(Properties config)
Checks if any implementation specific mailer configurations are incorrect
|
abstract void |
send(Collection<String> to,
Collection<String> ccs,
Collection<String> bccs,
Map<String,String> headers,
String subject,
String body)
Sends an email
|
abstract void |
send(Collection<String> to,
Collection<String> ccs,
Collection<String> bccs,
String subject,
String body)
Sends an email
|
abstract void |
send(javax.mail.internet.MimeMessage message)
Sends an email
|
abstract void |
send(String to,
Map<String,String> headers,
String subject,
String body)
Sends an email
|
abstract void |
send(String to,
String subject,
String body)
Sends an email
|
protected static String getConfigurationProperty(String key)
key - The configuration property keyprotected static String getConfigurationProperty(String key, String defaultValue)
key - The configuration property keydefaultValue - The default value to be returned if the actual value is nullprotected static Properties getConfiguration()
public static final void configure(InputStream input) throws IOException
input - The properties file input streamIOException - some error occurs reading from inputpublic static final void configure(Properties properties) throws IOException
IOExceptionpublic final boolean isDebug()
public final String getDebugAddress()
protected static javax.mail.internet.InternetAddress convertStringToAddress(String mail) throws MailerException
mail - The string email addressMailerException - address is not validprotected static Collection<javax.mail.internet.InternetAddress> convertStringsToAddressess(Collection<String> mails) throws MailerException
mails - The list of string addressesMailerException - some address is not validpublic static List<String> getList(String value)
value - the property valueprotected final boolean isValidConfiguration(Properties config)
config - The configuration propertiesprotected static final boolean isValidBasicConfiguration(Properties config)
config - The configuration propertiespublic static final boolean isValidEmail(String email)
email - The email address to be validated.protected abstract boolean isValidMailerConfiguration(Properties config)
config - the configuration propertiespublic abstract void send(javax.mail.internet.MimeMessage message)
throws MailerException
message - The Mime message object to be sentMailerException - some problem with the argumentspublic abstract void send(String to, String subject, String body) throws MailerException
to - The destination emailsubject - the message subjectbody - The message bodyMailerException - some problem with the argumentspublic abstract void send(String to, Map<String,String> headers, String subject, String body) throws MailerException
to - The destination emailheaders - A map with any header values to be added or overriddensubject - the message subjectbody - The message bodyMailerException - some problem with the argumentspublic abstract void send(Collection<String> to, Collection<String> ccs, Collection<String> bccs, String subject, String body) throws MailerException
to - The destination emailccs - Carbon copy addressesbccs - Carbon copy addressessubject - the message subjectbody - The message bodyMailerException - some problem with the argumentspublic abstract void send(Collection<String> to, Collection<String> ccs, Collection<String> bccs, Map<String,String> headers, String subject, String body) throws MailerException
to - The destination emailccs - Carbon copy addressesbccs - Carbon copy addressesheaders - A map with any header values to be added or overriddensubject - the message subjectbody - The message bodyMailerException - some problem with the argumentsCopyright © 2014–2018 Premium Minds. All rights reserved.