public class Emailer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Emailer.PasswordAuth |
static class |
Emailer.SendAction |
Modifier and Type | Field and Description |
---|---|
static Feature |
DEBUG_SEND |
static java.lang.String |
DEFAULT_ENCODING
Default string encoding to use.
|
static java.lang.String |
EMAIL_BYPASS_FORCE_ADDRESS |
static Feature |
EMAIL_DEFERRED_SEND |
static java.lang.String |
EMAIL_FORCE_ADDRESS |
static java.lang.String |
EMAIL_FROM_ADDRESS |
static java.lang.String |
EMAIL_FROM_NAME |
static Feature |
EMAILS_FEATURE |
static Feature |
HTML_ALTERNATIVE |
static Feature |
PASSWORD_RESET_SERVLET |
static java.lang.String |
SUPRESS_EMAIL_ATTR
Name of an AppContext attribute to supress emails from the current request.
|
Constructor and Description |
---|
Emailer(AppContext c) |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkAddress(java.lang.String email)
check the validity of an Email address
|
static boolean |
checkAddressList(java.lang.String list) |
void |
doSend(MimeMessage m)
Send the message
This might use the
CleanupService to send at the end of
a transaction |
MimeMessage |
doSendNow(MimeMessage m)
Send the message now.
|
static void |
errorEmail(AppContext conn,
Logger log,
java.lang.String subject,
java.lang.String text)
General email error report
|
static void |
errorEmail(AppContext conn,
Logger log,
java.lang.Throwable e,
java.util.Map props,
java.lang.String additional_info)
Send an error email
This is called within
EmailLogger so logging should always go through the
provided logger. |
protected AppContext |
getContext() |
java.lang.String |
getEmail(AppUser recipient) |
java.lang.String |
getEncoding() |
Logger |
getLogger() |
protected Session |
getSession() |
static Session |
getSession(AppContext conn) |
static void |
infoEmail(AppContext conn,
java.lang.String text)
General email information report
|
MimeMessage |
makeBlankEmail(AppContext conn,
java.lang.String[] notify_emails,
InternetAddress from,
java.lang.String subject)
make a blank email as a starting point
|
java.lang.String |
mapRecipients(java.lang.String sendto) |
static boolean |
needsEncoding(java.lang.String subject)
should we specify an encoding for the string
|
void |
newEmailRequest(AppUser person,
EmailChangeRequestFactory.EmailChangeRequest req)
Send an email requesting confirmation of a new Email address.
|
void |
newPassword(AppUser person,
PasswordAuthComposite comp)
Send an email with the person new password
|
void |
newRemoteHostLogin(AppUser person,
java.lang.String host) |
void |
newSignup(AppUser person,
java.lang.String new_password) |
void |
notificationEmail(AppUser person,
java.util.Set<java.lang.String> notices) |
static java.util.Set<InternetAddress> |
parseEmailList(java.lang.String list) |
void |
passwordChanged(AppUser person)
Notify user their password has been changed.
|
void |
passwordFailsExceeded(AppUser person)
Notify user their password has been locked-out.
|
static java.lang.String[] |
splitEmailList(java.lang.String list) |
boolean |
supressSend(Address a) |
void |
templateEmail(java.lang.String[] notify_emails,
TemplateFile email_template)
send an email from a template file to multiple recipients
|
MimeMessage |
templateMessage(AppUser recipient,
java.util.Hashtable headers,
TemplateFile email_template) |
MimeMessage |
templateMessage(AppUser recipient,
TemplateFile email_template)
Send an email based on a template file to a
AppUser |
MimeMessage |
templateMessage(java.lang.String[] notify_emails,
java.util.Hashtable headers,
InternetAddress from,
boolean multipart,
TemplateFile email_template) |
MimeMessage |
templateMessage(java.lang.String[] notify_emails,
java.util.Hashtable headers,
TemplateFile email_template)
make an email from a template file to multiple recipients with custom
headers
|
MimeMessage |
templateMessage(java.lang.String[] notify_emails,
java.lang.String header_prefix,
java.util.Hashtable headers,
InternetAddress from,
boolean multipart,
TemplateFile email_template,
java.util.Map<java.lang.String,java.lang.String> params) |
MimeMessage |
templateMessage(java.lang.String[] notify_emails,
TemplateFile email_template)
make an email from a template file to multiple recipients
|
MimeMessage |
templateMessage(java.lang.String sendto,
java.util.Hashtable h,
TemplateFile email_template) |
MimeMessage |
templateMessage(java.lang.String sendto,
java.util.Hashtable h,
TemplateFile email_template,
java.util.Map<java.lang.String,java.lang.String> params) |
public static final java.lang.String DEFAULT_ENCODING
public static final java.lang.String SUPRESS_EMAIL_ATTR
public static final java.lang.String EMAIL_FROM_NAME
public static final java.lang.String EMAIL_FROM_ADDRESS
public static final java.lang.String EMAIL_FORCE_ADDRESS
public static final java.lang.String EMAIL_BYPASS_FORCE_ADDRESS
public static final Feature EMAILS_FEATURE
public static final Feature PASSWORD_RESET_SERVLET
public static final Feature EMAIL_DEFERRED_SEND
public static final Feature HTML_ALTERNATIVE
public static final Feature DEBUG_SEND
public Emailer(AppContext c)
protected AppContext getContext()
public void newPassword(AppUser person, PasswordAuthComposite comp) throws java.lang.Exception
person
- new_password
- java.lang.Exception
public void newEmailRequest(AppUser person, EmailChangeRequestFactory.EmailChangeRequest req) throws java.lang.Exception
person
- req
- java.lang.Exception
public void newRemoteHostLogin(AppUser person, java.lang.String host) throws java.lang.Exception
java.lang.Exception
public void passwordChanged(AppUser person) throws java.lang.Exception
person
- new_password
- java.lang.Exception
public void passwordFailsExceeded(AppUser person) throws java.lang.Exception
person
- new_password
- java.lang.Exception
public void newSignup(AppUser person, java.lang.String new_password) throws java.lang.Exception
java.lang.Exception
public void notificationEmail(AppUser person, java.util.Set<java.lang.String> notices) throws java.lang.Exception
java.lang.Exception
public MimeMessage templateMessage(java.lang.String sendto, java.util.Hashtable h, TemplateFile email_template) throws java.io.IOException, MessagingException, InvalidArgument
java.io.IOException
MessagingException
InvalidArgument
public MimeMessage templateMessage(java.lang.String sendto, java.util.Hashtable h, TemplateFile email_template, java.util.Map<java.lang.String,java.lang.String> params) throws java.io.IOException, MessagingException, InvalidArgument
java.io.IOException
MessagingException
InvalidArgument
public java.lang.String mapRecipients(java.lang.String sendto)
public java.lang.String getEmail(AppUser recipient)
public MimeMessage templateMessage(AppUser recipient, TemplateFile email_template) throws java.io.IOException, MessagingException, InvalidArgument
AppUser
sendto
- email_template
- MimeMessage
java.io.IOException
MessagingException
InvalidArgument
public MimeMessage templateMessage(AppUser recipient, java.util.Hashtable headers, TemplateFile email_template) throws java.io.IOException, MessagingException, InvalidArgument
java.io.IOException
MessagingException
InvalidArgument
public boolean supressSend(Address a)
public void doSend(MimeMessage m) throws MessagingException
CleanupService
to send at the end of
a transactionm
- MessagingException
public MimeMessage doSendNow(MimeMessage m) throws MessagingException
m
- MessagingException
public MimeMessage templateMessage(java.lang.String[] notify_emails, java.util.Hashtable headers, TemplateFile email_template) throws MessagingException, java.io.UnsupportedEncodingException, InvalidArgument
notify_emails
- destination addressesheaders
- Hashtable of extra header infoemail_template
- TemplateFile to sue to generate messagejava.io.UnsupportedEncodingException
MessagingException
InvalidArgument
public MimeMessage templateMessage(java.lang.String[] notify_emails, java.util.Hashtable headers, InternetAddress from, boolean multipart, TemplateFile email_template) throws MessagingException, java.io.UnsupportedEncodingException, InvalidArgument
MessagingException
java.io.UnsupportedEncodingException
InvalidArgument
public MimeMessage templateMessage(java.lang.String[] notify_emails, java.lang.String header_prefix, java.util.Hashtable headers, InternetAddress from, boolean multipart, TemplateFile email_template, java.util.Map<java.lang.String,java.lang.String> params) throws MessagingException, java.io.UnsupportedEncodingException, InvalidArgument
MessagingException
java.io.UnsupportedEncodingException
InvalidArgument
public java.lang.String getEncoding()
public MimeMessage makeBlankEmail(AppContext conn, java.lang.String[] notify_emails, InternetAddress from, java.lang.String subject) throws MessagingException, AddressException, java.io.UnsupportedEncodingException
conn
- AppContext
notify_emails
- from
- Address to send from, may be blanksubject
- MessagingException
AddressException
java.io.UnsupportedEncodingException
public Logger getLogger()
public static boolean needsEncoding(java.lang.String subject)
subject
- protected Session getSession()
conn
- log
- public static Session getSession(AppContext conn)
public void templateEmail(java.lang.String[] notify_emails, TemplateFile email_template) throws java.io.UnsupportedEncodingException, MessagingException, InvalidArgument
notify_emails
- email_template
- java.io.UnsupportedEncodingException
MessagingException
InvalidArgument
public MimeMessage templateMessage(java.lang.String[] notify_emails, TemplateFile email_template) throws java.io.UnsupportedEncodingException, MessagingException, InvalidArgument
notify_emails
- email_template
- java.io.UnsupportedEncodingException
MessagingException
InvalidArgument
public static boolean checkAddress(java.lang.String email)
email
- String containing addresspublic static void errorEmail(AppContext conn, Logger log, java.lang.String subject, java.lang.String text)
conn
- text
- public static void errorEmail(AppContext conn, Logger log, java.lang.Throwable e, java.util.Map props, java.lang.String additional_info) throws java.lang.Exception
EmailLogger
so logging should always go through the
provided logger. We need to be careful to recover from errors if we can so that we
can still send some email even if some things are failingconn
- log
- Logger (optional)props
- e
- additional_info
- java.lang.Exception
public static void infoEmail(AppContext conn, java.lang.String text)
conn
- text
- public static java.lang.String[] splitEmailList(java.lang.String list)
public static java.util.Set<InternetAddress> parseEmailList(java.lang.String list) throws AddressException
AddressException
public static boolean checkAddressList(java.lang.String list)