in server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java [298:396]
public void process() throws MessagingException {
// Log delivery attempt
LOGGER.debug("Attempting delivery of message with id. {}", getMessageIn().getMessageID());
// Determine the intended recipient
MailAddress intendedRecipient = getIntendedRecipient();
setRecipientNotFound(null == intendedRecipient);
if (isRecipientNotFound()) {
if (isDeferRecipientNotFound()) {
String messageID = getMessageIn().getMessageID();
if (!getDeferredRecipientNotFoundMessageIDs().contains(messageID)) {
getDeferredRecipientNotFoundMessageIDs().add(messageID);
LOGGER.debug("Deferred processing of message for which the intended recipient could not be found. Message ID: {}", messageID);
return;
} else {
getDeferredRecipientNotFoundMessageIDs().remove(messageID);
LOGGER.debug("Processing deferred message for which the intended recipient could not be found. Message ID: {}", messageID);
}
}
if (isRejectRecipientNotFound()) {
rejectRecipientNotFound();
return;
}
intendedRecipient = getRecipient();
StringBuilder messageBuffer = new StringBuilder("Intended recipient not found. Using configured recipient as new envelope recipient - ");
messageBuffer.append(intendedRecipient);
messageBuffer.append('.');
logStatusInfo(messageBuffer.toString());
}
// Set the filter states
setBlacklistedRecipient(isBlacklistedRecipient(intendedRecipient));
setRemoteRecipient(!isLocalServer(intendedRecipient));
try {
setUserUndefined(!isLocalRecipient(intendedRecipient));
} catch (UsersRepositoryException e) {
throw new MessagingException("Unable to access USersRepository", e);
}
// Apply the filters. Return if rejected
if (isRejectBlacklisted() && isBlacklistedRecipient()) {
rejectBlacklistedRecipient(intendedRecipient);
return;
}
if (isRejectRemoteRecipient() && isRemoteRecipient()) {
rejectRemoteRecipient(intendedRecipient);
return;
}
if (isRejectUserUndefined() && isUserUndefined()) {
rejectUserUndefined(intendedRecipient);
return;
}
if (isRejectMaxMessageSizeExceeded() && isMaxMessageSizeExceeded()) {
rejectMaxMessageSizeExceeded(getMessageIn().getSize());
return;
}
if (isRejectRemoteReceivedHeaderInvalid() && isRemoteReceivedHeaderInvalid()) {
rejectRemoteReceivedHeaderInvalid();
return;
}
// Create the mail
// If any of the mail addresses are malformed, we will get a
// ParseException.
// If the IP address and host name for the remote domain cannot
// be found, we will get an UnknownHostException.
// In both cases, we log the problem and
// return. The message disposition is defined by the
// <undeliverable> attributes.
Mail mail;
try {
mail = createMail(createMessage(), intendedRecipient);
} catch (ParseException ex) {
handleParseException(ex);
return;
} catch (UnknownHostException ex) {
handleUnknownHostException(ex);
return;
}
addMailAttributes(mail);
addErrorMessages(mail);
// If this mail is bouncing move it to the ERROR repository
if (isBouncing()) {
handleBouncing(mail);
return;
}
// OK, lets send that mail!
sendMail(mail);
}