public class EmailTransaction extends Object
This object allows emails to take part in transactional operations.
Any part of the code may send(Message)
emails using this transaction.
They get stored in memory, and only really get sent when commit()
is called.
This way, if an exception occurs after the email gets sent, and the operation is successfully
retried, the recipient only gets one email based on the successful operation and no emails
based on the unsuccessful operation.
There is no need to rollback this object if an operation has been not successful. Simply throw the object away.
Modifier and Type | Class and Description |
---|---|
static class |
EmailTransaction.MxSmtpConfiguration |
static class |
EmailTransaction.SmtpServerAddress |
static class |
EmailTransaction.SmtpServerConfiguration |
static class |
EmailTransaction.TlsSmtpServerAddress |
Constructor and Description |
---|
EmailTransaction(EmailTransaction.SmtpServerConfiguration server) |
Modifier and Type | Method and Description |
---|---|
void |
commit() |
String |
getEmailBodyForTesting(int idx) |
int |
getEmailCountForTesting() |
javax.mail.internet.MimeMessage |
newMimeMessage() |
static EmailTransaction.SmtpServerConfiguration |
parseAddress(String str)
Can be "foo" or "foo:123" or "foo:123|adrian|password" or "MX:foo.com"
|
void |
send(javax.mail.Message msg) |
public EmailTransaction(EmailTransaction.SmtpServerConfiguration server) throws ConfigurationException
ConfigurationException
public static EmailTransaction.SmtpServerConfiguration parseAddress(String str) throws ConfigurationException
ConfigurationException
public javax.mail.internet.MimeMessage newMimeMessage()
public void send(javax.mail.Message msg)
public void commit()
public int getEmailCountForTesting()
public String getEmailBodyForTesting(int idx)