synchronized(this.smtpDestinationMonitor) {
// If no timer was active send immeditately (usually the first email)
if (this.smtpTimeoutHandle == null) {
this.currentEmailData = null;
this.smtpTimeout.addTimeoutListener(new I_Timeout() {
public void timeout(Object userData) {
try {
smtpDestinationHelper.smtpClient.sendEmail(emailData);
} catch (Throwable e) {
e.printStackTrace();
}
}
}, 1, null); // after 1 milli, dispatch to timer thread
}
else {
// If a timer is active return, the timout will send the mail
this.currentEmailData = emailData;
return;
}
// Now span timer, other emails are collected until this timer elapses
if (this.smtpDestinationHelper.collectIntervall > 0) {
this.smtpTimeoutHandle = this.smtpTimeout.addTimeoutListener(new I_Timeout() {
public void timeout(Object userData) {
synchronized(smtpDestinationMonitor) {
smtpTimeoutHandle = null;
if (currentEmailData == null) return;
try {