@Override
public void data(Mail mail) throws RejectExceptionExt {
Maildrop maildrop = maildropRepository.borrowMaildrop(maildropName);
try {
MaildropAppender appender;
try {
appender = maildrop.allocateAppender();
} catch (LocalMailSystemException e) {
logger.error("Cannot accept mail because of a "
+ "maildrop failure", e);
throw new RejectExceptionExt(e.errorStatus());
}
OutputStream out;
try {
out = appender.getOutputStream();
} catch (LocalMailSystemException e) {
logger.error("Cannot accept mail because of a "
+ "maildrop failure", e);
appender.rollback();
throw new RejectExceptionExt(e.errorStatus());
}
try {
out.write(constructReturnPathLine(mail));
mail.mailData.writeTo(out);
} catch (IOException e) {
logger.error(
"Cannot accept mail because of an IO error "
+ "occured while the mail was written into the maildrop",
e);
appender.rollback();
throw new RejectExceptionExt(
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
}
try {
appender.commit();
} catch (LocalMailSystemException e) {
logger.error("Cannot accept mail because of a "
+ "maildrop failure", e);
throw new RejectExceptionExt(e.errorStatus());
}