T
- public abstract class ContactableEmailer<T extends Contactable> extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
dayStamp |
protected String |
hourStamp |
protected String |
minuteStamp |
protected Sandbox |
sandbox |
protected String |
template |
protected URL |
templateUrl |
protected T |
user |
protected String |
weekStamp |
Constructor and Description |
---|
ContactableEmailer(T user) |
ContactableEmailer(T user,
Map<String,Object> context) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkDefaultOptOut()
Apply default heuristics for opting out the user from email.
|
boolean |
checkOptOut()
Override this to check for additional conditions where the user might be
opted out.
|
String |
getCc()
Override this to set a custom list of CC addresses
|
protected Map<String,Object> |
getContext() |
String |
getEmailType()
The type of the email, used for logging, defaults to using the
Java class name, can be overrident
|
String |
getFromAddress()
Who is sending the email.
|
String |
getReplyTo()
Override this to set a custom-reply to address.
|
Sandbox |
getSandbox()
If not null, will render the email template with the sandbox, thus limiting
access in the template context to site-wide data.
|
abstract String |
getSubject()
Your email subject.
|
abstract String |
getTemplate()
The path to the jinja template.
|
String |
getUniqueKey()
This is used to prevent accidentally sending duplicate emails, by default the
uniqueKey is built from the subject, the contact id, the current week, and the email type.
|
protected boolean |
hasSeenKey()
Checks to see if the unique key for this email has been seen.
|
abstract boolean |
isTransactional()
Return true if this is an email that opt-out should not apply to.
|
protected void |
markSeenKey()
Mark the unique key as being seen.
|
protected void |
onPrepareContext()
Override this to prepare additional context variables.
|
void |
onPreSend()
Override this to do any additional actions just before the email is finally sent out.
|
protected void |
prepareContext() |
<Y extends ContactableEmailer> |
put(String key,
Object val)
Add additional data to the template context
|
boolean |
sendEmail() |
<E extends ContactableEmailer> |
setSandbox(Sandbox box) |
boolean |
shouldLog() |
protected void |
updateContext(Map<String,? extends Object> context) |
protected T extends Contactable user
protected URL templateUrl
protected String minuteStamp
public ContactableEmailer(T user)
public ContactableEmailer(T user, Map<String,Object> context)
public boolean sendEmail()
public boolean shouldLog()
public boolean checkDefaultOptOut()
public abstract boolean isTransactional()
public boolean checkOptOut()
public Sandbox getSandbox()
public <E extends ContactableEmailer> E setSandbox(Sandbox box)
public void onPreSend()
protected void prepareContext()
protected void onPrepareContext()
protected void updateContext(Map<String,? extends Object> context)
public <Y extends ContactableEmailer> Y put(String key, Object val)
key
- val
- public String getEmailType()
protected boolean hasSeenKey()
protected void markSeenKey()
public abstract String getTemplate()
public abstract String getSubject()
public String getFromAddress()
public String getReplyTo()
public String getUniqueKey()
protected Map<String,Object> getContext()
Copyright © 2016. All rights reserved.