Class MessageProcessor handles the delivery of
MimeMessages to the James input spool.
Messages written to the input spool always have the following Mail
Attributes set:
- org.apache.james.fetchmail.taskName (java.lang.String)
- The name of the fetch task that processed the message
- org.apache.james.fetchmail.folderName (java.lang.String)
- The name of the folder from which the message was fetched
Messages written to the input spool have the following Mail Attributes
set if the corresponding condition is satisfied:
- org.apache.james.fetchmail.isBlacklistedRecipient
- The recipient is in the configured blacklist
- org.apache.james.fetchmail.isMaxMessageSizeExceeded (java.lang.String)
- The message size exceeds the configured limit. An empty message is
written to the input spool. The Mail Attribute value is a String
representing the size of the original message in bytes.
- org.apache.james.fetchmail.isRecipientNotFound
- The recipient could not be found. Delivery is to the configured recipient.
See the discussion of delivery to a sole intended recipient below.
- org.apache.james.fetchmail.isRemoteRecievedHeaderInvalid
- The Receieved header at the index specified by parameter
remoteReceivedHeaderIndex is invalid.
- org.apache.james.fetchmail.isRemoteRecipient
- The recipient is on a remote host
- org.apache.james.fetchmail.isUserUndefined
- The recipient is on a localhost but not defined to James
- org.apache.james.fetchmail.isDefaultSenderLocalPart
- The local part of the sender address could not be obtained. The
default value has been used.
- org.apache.james.fetchmail.isDefaultSenderDomainPart
- The domain part of the sender address could not be obtained. The
default value has been used.
- org.apache.james.fetchmail.isDefaultRemoteAddress
- The remote address could not be determined. The default value
(localhost/127.0.0.1)has been used.
Configuration settings -
see org.apache.james.fetchmail.ParsedConfiguration
- control the messages that are written to the James input spool, those that
are rejected and what happens to messages that are rejected.
Rejection processing is based on the following filters:
- RejectRemoteRecipient
- Rejects recipients on remote hosts
- RejectBlacklistedRecipient
- Rejects recipients configured in a blacklist
- RejectUserUndefined
- Rejects recipients on local hosts who are not defined as James users
- RejectRecipientNotFound
- See the discussion of delivery to a sole intended recipient below
- RejectMaxMessageSizeExceeded
- Rejects messages whose size exceeds the configured limit
- RejectRemoteReceievedHeaderInvalid
- Rejects messages whose Received header is invalid.
Rejection processing is intentionally limited to managing the status of the
messages that are rejected on the server from which they were fetched. View
it as a simple automation of the manual processing an end-user would perform
through a mail client. Messages may be marked as seen or be deleted.
Further processing can be achieved by configuring to disable rejection for
one or more filters. This enables Messages that would have been rejected to
be written to the James input spool. The conditional Mail Attributes
described above identify the filter states. The Matcher/Mailet chain can
then be used to perform any further processing required, such as notifying
the Postmaster and/or sender, marking the message for error processing, etc.
Note that in the case of a message exceeding the message size limit, the
message that is written to the input spool has no content. This enables
configuration of a mailet notifying the sender that their mail has not been
delivered due to its size while maintaining the purpose of the filter which is
to avoid injecting excessively large messages into the input spool.
Delivery is to a sole intended recipient. The recipient is determined in the
following manner:
- If isIgnoreIntendedRecipient(), use the configured recipient
- If the Envelope contains a for: stanza, use the recipient in the stanza
- If the Message has a sole intended recipient, use this recipient
- If not rejectRecipientNotFound(), use the configured recipient
If a recipient cannot be determined after these steps, the message is
rejected.
Every delivered message CURRENTLY has an "X-fetched-from" header added
containing the name of the fetch task. Its primary uses are to detect bouncing
mail and provide backwards compatibility with the fetchPop task that inserted
this header to enable injected messages to be detected in the Matcher/Mailet
chain. This header is DEPRECATED and WILL BE REMOVED in a future version of
fetchmail. Use the Mail Attribute org.apache.james.fetchmail.taskName
instead.
MessageProcessor is as agnostic as it can be about the format
and contents of the messages it delivers. There are no RFCs that govern its
behavior. The most releveant RFCs relate to the exchange of messages between
MTA servers, but not POP3 or IMAP servers which are normally end-point
servers and not expected to re-inject mail into MTAs. None the less, the
intent is to conform to the 'spirit' of the RFCs.
MessageProcessor relies on the MTA (James in this
implementation) to manage and validate the injected mail just as it would
when receiving mail from an upstream MTA.
The only correction applied by MessageProcessor is to correct a
missing or partial sender address. If the sender address can not be obtained,
the default local part and default domain part is added. If the sender domain
part is absent, the default domain part is added.
Mail with corrections applied to the sender address will most likely pass
Matcher tests on the sender that they might otherwise fail. The
Mail Attributes org.apache.james.fetchmail.isDefaultSenderLocalPart
and org.apache.james.fetchmail.isDefaultSenderDomainPart are added
to the injected mail to enable such mail to be detected and processed accordingly.
The status of messages on the server from which they were fetched that
cannot be injected into the input spool due to non-correctable errors is
determined by the undeliverable configuration options.
|