Methods Summary |
---|
protected void | addErrorMessages(org.apache.mailet.Mail mail)Adds any required error messages to a Mail .
if (isMaxMessageSizeExceeded().booleanValue())
{
StringBuffer msgBuffer =
new StringBuffer("550 - Rejected - This message has been rejected as the message size of ");
msgBuffer.append(getMessageIn().getSize() * 1000 / 1024 / 1000f);
msgBuffer.append("KB exceeds the maximum permitted size of ");
msgBuffer.append(getMaxMessageSizeLimit() / 1024);
msgBuffer.append("KB.");
mail.setErrorMessage(msgBuffer.toString());
}
|
protected void | addMailAttributes(org.apache.mailet.Mail aMail)Adds the mail attributes to a Mail .
aMail.setAttribute(
getAttributePrefix() + "taskName",
getFetchTaskName());
aMail.setAttribute(
getAttributePrefix() + "folderName",
getMessageIn().getFolder().getFullName());
if (isRemoteRecipient())
aMail.setAttribute(
getAttributePrefix() + "isRemoteRecipient",
null);
if (isUserUndefined())
aMail.setAttribute(getAttributePrefix() + "isUserUndefined", null);
if (isBlacklistedRecipient())
aMail.setAttribute(
getAttributePrefix() + "isBlacklistedRecipient",
null);
if (isRecipientNotFound())
aMail.setAttribute(
getAttributePrefix() + "isRecipientNotFound",
null);
if (isMaxMessageSizeExceeded().booleanValue())
aMail.setAttribute(
getAttributePrefix() + "isMaxMessageSizeExceeded",
new Integer(getMessageIn().getSize()).toString());
if (isRemoteReceivedHeaderInvalid().booleanValue())
aMail.setAttribute(
getAttributePrefix() + "isRemoteReceivedHeaderInvalid",
null);
if (isDefaultSenderLocalPart())
aMail.setAttribute(
getAttributePrefix() + "isDefaultSenderLocalPart",
null);
if (isDefaultSenderDomainPart())
aMail.setAttribute(
getAttributePrefix() + "isDefaultSenderDomainPart",
null);
if (isDefaultRemoteAddress())
aMail.setAttribute(
getAttributePrefix() + "isDefaultRemoteAddress",
null);
|
protected java.lang.Boolean | computeMaxMessageSizeExceeded()Compute the maxMessageSizeExceeded.
if (0 == getMaxMessageSizeLimit())
return Boolean.FALSE;
return new Boolean(getMessageIn().getSize() > getMaxMessageSizeLimit());
|
protected java.lang.String | computeRemoteAddress()Answer the IP Address of the remote server for the message being
processed.
String domain = getRemoteDomain();
String address = null;
String validatedAddress = null;
int ipAddressStart = domain.indexOf('[");
int ipAddressEnd = -1;
if (ipAddressStart > -1)
ipAddressEnd = domain.indexOf(']", ipAddressStart);
if (ipAddressEnd > -1)
address = domain.substring(ipAddressStart + 1, ipAddressEnd);
else
{
int hostNameEnd = domain.indexOf(' ");
if (hostNameEnd == -1)
hostNameEnd = domain.length();
address = domain.substring(0, hostNameEnd);
}
validatedAddress = org.apache.james.dnsserver.DNSServer.getByName(address).getHostAddress();
return validatedAddress;
|
protected java.lang.String | computeRemoteDomain()Method computeRemoteDomain answers a String that is the
RFC2822 compliant "Received : from" domain extracted from the message
being processed for the remote domain that sent the message.
Often the remote domain is the domain that sent the message to the
host of the message store, the second "received" header, which has an
index of 1. Other times, messages may be received by a edge mail server
and relayed internally through one or more internal mail servers prior
to arriving at the message store host. In these cases the index is
1 + the number of internal servers through which a mail passes.
The index of the header to use is specified by the configuration
parameter RemoteReceivedHeaderIndex . This is set to
point to the received header prior to the remote mail server, the one
prior to the edge mail server.
"received" headers are searched starting at the specified index.
If a domain in the "received" header is not found, successively closer
"received" headers are tried. If a domain is not found in this way, the
local machine is used as the domain. Finally, if the local domain cannot
be determined, the local address 127.0.0.1 is used.
StringBuffer domainBuffer = new StringBuffer();
String[] headers = null;
if (getRemoteReceivedHeaderIndex() > -1)
headers = getMessageIn().getHeader(RFC2822Headers.RECEIVED);
// There are RECEIVED headers if the array is not null
// and its length at is greater than 0
boolean hasHeaders = (null == headers ? false : headers.length > 0);
// If there are RECEIVED headers try and extract the domain
if (hasHeaders)
{
final String headerTokens = " \n\r";
// Search the headers for a domain
for (int headerIndex =
headers.length > getRemoteReceivedHeaderIndex()
? getRemoteReceivedHeaderIndex()
: headers.length - 1;
headerIndex >= 0 && domainBuffer.length() == 0;
headerIndex--)
{
// Find the "from" token
StringTokenizer tokenizer =
new StringTokenizer(headers[headerIndex], headerTokens);
boolean inFrom = false;
while (!inFrom && tokenizer.hasMoreTokens())
inFrom = tokenizer.nextToken().equals("from");
// Add subsequent tokens to the domain buffer until another
// field is encountered or there are no more tokens
while (inFrom && tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken();
if (inFrom =
getRFC2822RECEIVEDHeaderFields().indexOf(token) == -1)
{
domainBuffer.append(token);
domainBuffer.append(' ");
}
}
}
}
// If a domain was not found, the default is the local host and
// if we cannot resolve this, the local address 127.0.0.1
// Note that earlier versions of this code simply used 'localhost'
// which works fine with java.net but is not resolved by dnsjava
// which was introduced in v2.2.0. See Jira issue JAMES-302.
if (domainBuffer.length() == 0)
{
try
{
InetAddress addr1 = java.net.InetAddress.getLocalHost();
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which getCanonicalHostName()
// does the job for us
InetAddress addr2 =
java.net.InetAddress.getByName(addr1.getHostAddress());
InetAddress addr3 =
java.net.InetAddress.getByName(addr2.getHostName());
domainBuffer.append(addr3.getHostName());
}
catch (UnknownHostException ue)
{
domainBuffer.append("[127.0.0.1]");
}
}
return domainBuffer.toString().trim();
|
protected java.lang.String | computeRemoteHostName()Answer the Canonical host name of the remote server for the message
being processed.
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which get getCanonicalHostName()
// does the job for us
InetAddress addr1 = org.apache.james.dnsserver.DNSServer.getByName(getRemoteAddress());
InetAddress addr2 = org.apache.james.dnsserver.DNSServer.getByName(addr1.getHostAddress());
return addr2.getHostName();
|
protected java.lang.Boolean | computeRemoteReceivedHeaderInvalid()Computes the remoteReceivedHeaderInvalid.
Boolean isInvalid = Boolean.FALSE;
try
{
getRemoteAddress();
}
catch (UnknownHostException e)
{
isInvalid = Boolean.TRUE;
}
return isInvalid;
|
protected javax.mail.internet.MimeMessage | createEmptyMessage()Method createEmptyMessage answers a new
MimeMessage from the fetched message with the message
contents removed.
// Create an empty messsage
MimeMessage messageOut = new MimeMessage(getSession());
// Propogate the headers and subject
Enumeration headersInEnum = getMessageIn().getAllHeaderLines();
while (headersInEnum.hasMoreElements())
messageOut.addHeaderLine((String) headersInEnum.nextElement());
messageOut.setSubject(getMessageIn().getSubject());
// Add empty text
messageOut.setText("");
// Save
messageOut.saveChanges();
return messageOut;
|
protected org.apache.mailet.Mail | createMail(javax.mail.internet.MimeMessage message, org.apache.mailet.MailAddress recipient)Method createMail creates a new Mail .
Collection recipients = new ArrayList(1);
recipients.add(recipient);
MailImpl mail =
new MailImpl(getServer().getId(), getSender(), recipients, message);
// Ensure the mail is created with non-null remote host name and address,
// otherwise the Mailet chain may go splat!
if (getRemoteAddress() == null || getRemoteHostName() == null)
{
mail.setRemoteAddr("127.0.0.1");
mail.setRemoteHost("localhost");
setDefaultRemoteAddress(true);
logStatusInfo("Remote address could not be determined. Using localhost/127.0.0.1");
}
else
{
mail.setRemoteAddr(getRemoteAddress());
mail.setRemoteHost(getRemoteHostName());
setDefaultRemoteAddress(false);
}
if (getLogger().isDebugEnabled())
{
StringBuffer messageBuffer =
new StringBuffer("Created mail with name: ");
messageBuffer.append(mail.getName());
messageBuffer.append(", sender: ");
messageBuffer.append(mail.getSender());
messageBuffer.append(", recipients: ");
Iterator recipientIterator = mail.getRecipients().iterator();
while (recipientIterator.hasNext())
{
messageBuffer.append(recipientIterator.next());
messageBuffer.append(' ");
}
messageBuffer.append(", remote address: ");
messageBuffer.append(mail.getRemoteAddr());
messageBuffer.append(", remote host name: ");
messageBuffer.append(mail.getRemoteHost());
messageBuffer.append('.");
getLogger().debug(messageBuffer.toString());
}
return mail;
|
protected javax.mail.internet.MimeMessage | createMessage()Method createMessage answers a new MimeMessage from the
fetched message.
If the maximum message size is exceeded, an empty message is created,
else the new message is a copy of the received message.
// Create a new messsage from the received message
MimeMessage messageOut = null;
if (isMaxMessageSizeExceeded().booleanValue())
messageOut = createEmptyMessage();
else
messageOut = new MimeMessage(getMessageIn());
// set the X-fetched headers
// Note this is still required to detect bouncing mail and
// for backwards compatibility with fetchPop
messageOut.addHeader("X-fetched-from", getFetchTaskName());
return messageOut;
|
protected java.lang.String | getEnvelopeRecipient(javax.mail.internet.MimeMessage msg)Method getEnvelopeRecipient answers the recipient if found else null.
Try and parse the "for" parameter from a Received header
Maybe not the most accurate parsing in the world but it should do
I opted not to use ORO (maybe I should have)
String res = getCustomRecipientHeader();
if (res != null && res.length() > 0) {
String[] headers = msg.getHeader(getCustomRecipientHeader());
if (headers != null) {
String mailFor = headers[0];
if (mailFor.startsWith("<") && mailFor.endsWith(">"))
mailFor = mailFor.substring(1, (mailFor.length() - 1));
return mailFor;
}
} else {
try
{
Enumeration enumeration =
msg.getMatchingHeaderLines(new String[] { "Received" });
while (enumeration.hasMoreElements())
{
String received = (String) enumeration.nextElement();
int nextSearchAt = 0;
int i = 0;
int start = 0;
int end = 0;
boolean hasBracket = false;
boolean usableAddress = false;
while (!usableAddress && (i != -1))
{
hasBracket = false;
i = received.indexOf("for ", nextSearchAt);
if (i > 0)
{
start = i + 4;
end = 0;
nextSearchAt = start;
for (int c = start; c < received.length(); c++)
{
char ch = received.charAt(c);
switch (ch)
{
case '<" :
hasBracket = true;
continue;
case '@" :
usableAddress = true;
continue;
case ' " :
end = c;
break;
case ';" :
end = c;
break;
}
if (end > 0)
break;
}
}
}
if (usableAddress)
{
// lets try and grab the email address
String mailFor = received.substring(start, end);
// strip the <> around the address if there are any
if (mailFor.startsWith("<") && mailFor.endsWith(">"))
mailFor = mailFor.substring(1, (mailFor.length() - 1));
return mailFor;
}
}
}
catch (MessagingException me)
{
logStatusWarn("No Received headers found.");
}
}
return null;
|
protected org.apache.mailet.MailAddress | getIntendedRecipient()Method getIntendedRecipient answers the sole intended recipient else null.
// If the original recipient should be ignored, answer the
// hard-coded recipient
if (isIgnoreRecipientHeader())
{
StringBuffer messageBuffer =
new StringBuffer("Ignoring recipient header. Using configured recipient as new envelope recipient: ");
messageBuffer.append(getRecipient());
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return getRecipient();
}
// If we can determine who the message was received for, answer
// the target recipient
String targetRecipient = getEnvelopeRecipient(getMessageIn());
if (targetRecipient != null)
{
MailAddress recipient = new MailAddress(targetRecipient);
StringBuffer messageBuffer =
new StringBuffer("Using original envelope recipient as new envelope recipient: ");
messageBuffer.append(recipient);
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return recipient;
}
// If we can determine the intended recipient from all of the recipients,
// answer the intended recipient. This requires that there is exactly one
// recipient answered by getAllRecipients(), which examines the TO: CC: and
// BCC: headers
Address[] allRecipients = getMessageIn().getAllRecipients();
if (allRecipients.length == 1)
{
MailAddress recipient =
new MailAddress((InternetAddress) allRecipients[0]);
StringBuffer messageBuffer =
new StringBuffer("Using sole recipient header address as new envelope recipient: ");
messageBuffer.append(recipient);
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return recipient;
}
return null;
|
protected javax.mail.internet.MimeMessage | getMessageIn()Returns the messageIn.
return fieldMessageIn;
|
public static java.lang.String | getRFC2822RECEIVEDHeaderFields()Returns the rFC2822RECEIVEDHeaderFields.
return fieldRFC2822RECEIVEDHeaderFields;
|
protected java.lang.String | getRemoteAddress()Returns the remoteAddress, lazily initialised as required.
String remoteAddress;
if (null == (remoteAddress = getRemoteAddressBasic()))
{
updateRemoteAddress();
return getRemoteAddress();
}
return remoteAddress;
|
private java.lang.String | getRemoteAddressBasic()Returns the remoteAddress.
return fieldRemoteAddress;
|
protected java.lang.String | getRemoteDomain()Returns the remoteDomain, lazily initialised as required.
String remoteDomain;
if (null == (remoteDomain = getRemoteDomainBasic()))
{
updateRemoteDomain();
return getRemoteDomain();
}
return remoteDomain;
|
private java.lang.String | getRemoteDomainBasic()Returns the remoteDomain.
return fieldRemoteDomain;
|
protected java.lang.String | getRemoteHostName()Returns the remoteHostName, lazily initialised as required.
String remoteHostName;
if (null == (remoteHostName = getRemoteHostNameBasic()))
{
updateRemoteHostName();
return getRemoteHostName();
}
return remoteHostName;
|
private java.lang.String | getRemoteHostNameBasic()Returns the remoteHostName.
return fieldRemoteHostName;
|
protected org.apache.mailet.MailAddress | getSender()
Method getSender answers a MailAddress for the sender.
When the sender local part and/or domain part can not be obtained
from the mail, default values are used. The flags
'defaultSenderLocalPart' and 'defaultSenderDomainPart' are set
accordingly.
String from = null;
InternetAddress internetAddress = null;
try {
from = ((InternetAddress) getMessageIn().getFrom()[0]).getAddress().trim();
setDefaultSenderLocalPart(false);
}
catch (Exception _) {
from = getDefaultLocalPart();
setDefaultSenderLocalPart(true);
StringBuffer buffer = new StringBuffer(32);
buffer.append("Sender localpart is absent. Using default value (");
buffer.append(getDefaultLocalPart());
buffer.append(')");
logStatusInfo(buffer.toString());
}
// Check for domain part, add default if missing
if (from.indexOf('@") < 0)
{
StringBuffer fromBuffer = new StringBuffer(from);
fromBuffer.append('@");
fromBuffer.append(getDefaultDomainName());
internetAddress = new InternetAddress(fromBuffer.toString());
setDefaultSenderDomainPart(true);
StringBuffer buffer = new StringBuffer(32);
buffer.append("Sender domain is absent. Using default value (");
buffer.append(getDefaultDomainName());
buffer.append(')");
logStatusInfo(buffer.toString());
}
else
{
internetAddress = new InternetAddress(from);
setDefaultSenderDomainPart(false);
}
return new MailAddress(internetAddress);
|
protected java.lang.StringBuffer | getStatusReport(java.lang.String detailMsg)Answer a StringBuffer containing a message reflecting
the current status of the message being processed.
StringBuffer messageBuffer = new StringBuffer(detailMsg);
if (detailMsg.length() > 0)
messageBuffer.append(' ");
messageBuffer.append("Message ID: ");
messageBuffer.append(getMessageIn().getMessageID());
messageBuffer.append(". Flags: Seen = ");
messageBuffer.append(new Boolean(isMessageSeen()));
messageBuffer.append(", Delete = ");
messageBuffer.append(new Boolean(isMessageDeleted()));
messageBuffer.append('.");
return messageBuffer;
|
protected void | handleBouncing(org.apache.mailet.Mail mail)Method handleBouncing sets the Mail state to ERROR and delete from
the message store.
mail.setState(Mail.ERROR);
setMessageDeleted();
mail.setErrorMessage(
"This mail from FetchMail task "
+ getFetchTaskName()
+ " seems to be bouncing!");
logStatusError("Message is bouncing! Deleted from message store and moved to the Error repository.");
|
protected void | handleMarkSeenNotPermanent()Handler for when the folder does not support the SEEN flag.
The default behaviour implemented here is to log a warning and set the
flag anyway.
Subclasses may choose to override this and implement their own
solutions.
getMessageIn().setFlag(Flags.Flag.SEEN, true);
logStatusWarn("Message marked as SEEN, but the folder does not support a permanent SEEN flag.");
|
protected void | handleParseException(javax.mail.internet.ParseException ex)Method handleParseException.
// Update the flags of the received message
if (!isLeaveUndeliverable())
setMessageDeleted();
if (isMarkUndeliverableSeen())
setMessageSeen();
logStatusWarn("Message could not be delivered due to an error parsing a mail address.");
if (getLogger().isDebugEnabled())
{
StringBuffer messageBuffer =
new StringBuffer("UNDELIVERABLE Message ID: ");
messageBuffer.append(getMessageIn().getMessageID());
getLogger().debug(messageBuffer.toString(), ex);
}
|
protected void | handleUnknownHostException(java.net.UnknownHostException ex)Method handleUnknownHostException.
// Update the flags of the received message
if (!isLeaveUndeliverable())
setMessageDeleted();
if (isMarkUndeliverableSeen())
setMessageSeen();
logStatusWarn("Message could not be delivered due to an error determining the remote domain.");
if (getLogger().isDebugEnabled())
{
StringBuffer messageBuffer =
new StringBuffer("UNDELIVERABLE Message ID: ");
messageBuffer.append(getMessageIn().getMessageID());
getLogger().debug(messageBuffer.toString(), ex);
}
|
protected boolean | isBlacklistedRecipient(org.apache.mailet.MailAddress recipient)Method isBlacklistedRecipient.
return getBlacklist().contains(recipient);
|
protected boolean | isBlacklistedRecipient()Returns the Blacklisted.
return fieldBlacklistedRecipient;
|
protected boolean | isBouncing()Check if this mail has been bouncing by counting the X-fetched-from
headers for this task
Enumeration enumeration =
getMessageIn().getMatchingHeaderLines(
new String[] { "X-fetched-from" });
int count = 0;
while (enumeration.hasMoreElements())
{
String header = (String) enumeration.nextElement();
if (header.equals(getFetchTaskName()))
count++;
}
return count >= 3;
|
protected boolean | isDefaultRemoteAddress()Returns the defaultRemoteAddress.
return fieldDefaultRemoteAddress;
|
protected boolean | isDefaultSenderDomainPart()Returns the defaultSenderDomainPart.
return fieldDefaultSenderDomainPart;
|
protected boolean | isDefaultSenderLocalPart()Returns the defaultSenderLocalPart.
return fieldDefaultSenderLocalPart;
|
protected boolean | isLocalRecipient(org.apache.mailet.MailAddress recipient)Method isLocalRecipient.
return isLocalUser(recipient) && isLocalServer(recipient);
|
protected boolean | isLocalServer(org.apache.mailet.MailAddress recipient)Method isLocalServer.
return getServer().isLocalServer(recipient.getHost());
|
protected boolean | isLocalUser(org.apache.mailet.MailAddress recipient)Method isLocalUser.
return getLocalUsers().containsCaseInsensitive(recipient.getUser());
|
protected java.lang.Boolean | isMaxMessageSizeExceeded()Returns the maxMessageSizeExceeded, lazily initialised as required.
Boolean isMaxMessageSizeExceeded = null;
if (null
== (isMaxMessageSizeExceeded = isMaxMessageSizeExceededBasic()))
{
updateMaxMessageSizeExceeded();
return isMaxMessageSizeExceeded();
}
return isMaxMessageSizeExceeded;
|
private java.lang.Boolean | isMaxMessageSizeExceededBasic()Returns the maxMessageSizeExceeded.
return fieldMaxMessageSizeExceeded;
|
protected boolean | isMessageDeleted()Is the DELETED flag set?
return getMessageIn().isSet(Flags.Flag.DELETED);
|
protected boolean | isMessageSeen()Is the SEEN flag set?
return getMessageIn().isSet(Flags.Flag.SEEN);
|
protected boolean | isPreviouslyUnprocessed()Returns boolean indicating if the message to be delivered
was unprocessed in a previous delivery attempt.
return true;
|
protected boolean | isRecipientNotFound()Returns the recipientNotFound.
return fieldRecipientNotFound;
|
protected java.lang.Boolean | isRemoteReceivedHeaderInvalid()Returns the remoteReceivedHeaderInvalid, lazily initialised.
Boolean isInvalid = null;
if (null == (isInvalid = isRemoteReceivedHeaderInvalidBasic()))
{
updateRemoteReceivedHeaderInvalid();
return isRemoteReceivedHeaderInvalid();
}
return isInvalid;
|
private java.lang.Boolean | isRemoteReceivedHeaderInvalidBasic()Returns the remoteReceivedHeaderInvalid.
return fieldRemoteReceivedHeaderInvalid;
|
protected boolean | isRemoteRecipient()Returns the localRecipient.
return fieldRemoteRecipient;
|
protected boolean | isUserUndefined()Returns the userUndefined.
return fieldUserUndefined;
|
protected void | logStatusError(java.lang.String detailMsg)Log the status the current message as ERROR.
getLogger().error(getStatusReport(detailMsg).toString());
|
protected void | logStatusInfo(java.lang.String detailMsg)Log the status of the current message as INFO.
getLogger().info(getStatusReport(detailMsg).toString());
|
protected void | logStatusWarn(java.lang.String detailMsg)Log the status the current message as WARN.
getLogger().warn(getStatusReport(detailMsg).toString());
|
public void | process()Method process attempts to deliver a fetched message.
// Log delivery attempt
if (getLogger().isDebugEnabled())
{
StringBuffer logMessageBuffer =
new StringBuffer("Attempting delivery of message with id. ");
logMessageBuffer.append(getMessageIn().getMessageID());
getLogger().debug(logMessageBuffer.toString());
}
// 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);
if (getLogger().isDebugEnabled())
{
StringBuffer messageBuffer =
new StringBuffer("Deferred processing of message for which the intended recipient could not be found. Message ID: ");
messageBuffer.append(messageID);
getLogger().debug(messageBuffer.toString());
}
return;
}
else
{
getDeferredRecipientNotFoundMessageIDs().remove(messageID);
if (getLogger().isDebugEnabled())
{
StringBuffer messageBuffer =
new StringBuffer("Processing deferred message for which the intended recipient could not be found. Message ID: ");
messageBuffer.append(messageID);
getLogger().debug(messageBuffer.toString());
}
}
}
if (isRejectRecipientNotFound())
{
rejectRecipientNotFound();
return;
}
intendedRecipient = getRecipient();
StringBuffer messageBuffer =
new StringBuffer("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));
setUserUndefined(!isLocalRecipient(intendedRecipient));
// 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().booleanValue())
{
rejectMaxMessageSizeExceeded(getMessageIn().getSize());
return;
}
if (isRejectRemoteReceivedHeaderInvalid()
&& isRemoteReceivedHeaderInvalid().booleanValue())
{
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 = null;
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);
|
protected void | rejectBlacklistedRecipient(org.apache.mailet.MailAddress recipient)Method rejectBlacklistedRecipient.
// Update the flags of the received message
if (!isLeaveBlacklisted())
setMessageDeleted();
if (isMarkBlacklistedSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail intended for blacklisted recipient: ");
messageBuffer.append(recipient);
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | rejectMaxMessageSizeExceeded(int messageSize)Method rejectMaxMessageSizeExceeded.
// Update the flags of the received message
if (!isLeaveMaxMessageSizeExceeded())
setMessageDeleted();
if (isMarkMaxMessageSizeExceededSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail exceeding message size limit. Message size: ");
messageBuffer.append(messageSize/1024);
messageBuffer.append("KB.");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | rejectRecipientNotFound()Method rejectRecipientNotFound.
// Update the flags of the received message
if (!isLeaveRecipientNotFound())
setMessageDeleted();
if (isMarkRecipientNotFoundSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail for which a sole intended recipient could not be found.");
messageBuffer.append(" Recipients: ");
Address[] allRecipients = getMessageIn().getAllRecipients();
for (int i = 0; i < allRecipients.length; i++)
{
messageBuffer.append(allRecipients[i]);
messageBuffer.append(' ");
}
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | rejectRemoteReceivedHeaderInvalid()Method rejectRemoteReceivedHeaderInvalid.
// Update the flags of the received message
if (!isLeaveRemoteReceivedHeaderInvalid())
setMessageDeleted();
if (isMarkRemoteReceivedHeaderInvalidSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail with an invalid Received: header at index ");
messageBuffer.append(getRemoteReceivedHeaderIndex());
messageBuffer.append(".");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | rejectRemoteRecipient(org.apache.mailet.MailAddress recipient)Method rejectRemoteRecipient.
// Update the flags of the received message
if (!isLeaveRemoteRecipient())
setMessageDeleted();
if (isMarkRemoteRecipientSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail intended for remote recipient: ");
messageBuffer.append(recipient);
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | rejectUserUndefined(org.apache.mailet.MailAddress recipient)Method rejectUserUndefined.
// Update the flags of the received message
if (!isLeaveUserUndefined())
setMessageDeleted();
if (isMarkUserUndefinedSeen())
setMessageSeen();
StringBuffer messageBuffer =
new StringBuffer("Rejected mail intended for undefined user: ");
messageBuffer.append(recipient);
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
return;
|
protected void | sendMail(org.apache.mailet.Mail mail)Method sendMail.
// send the mail
getServer().sendMail(mail);
// Update the flags of the received message
if (!isLeave())
setMessageDeleted();
if (isMarkSeen())
setMessageSeen();
// Log the status
StringBuffer messageBuffer =
new StringBuffer("Spooled message to recipients: ");
Iterator recipientIterator = mail.getRecipients().iterator();
while (recipientIterator.hasNext())
{
messageBuffer.append(recipientIterator.next());
messageBuffer.append(' ");
}
messageBuffer.append('.");
logStatusInfo(messageBuffer.toString());
|
protected void | setBlacklistedRecipient(boolean blacklisted)Sets the Blacklisted.
fieldBlacklistedRecipient = blacklisted;
|
protected void | setDefaultRemoteAddress(boolean defaultRemoteAddress)Sets the defaultRemoteAddress.
fieldDefaultRemoteAddress = defaultRemoteAddress;
|
protected void | setDefaultSenderDomainPart(boolean defaultSenderDomainPart)Sets the defaultSenderDomainPart.
fieldDefaultSenderDomainPart = defaultSenderDomainPart;
|
protected void | setDefaultSenderLocalPart(boolean defaultSenderLocalPart)Sets the defaultSenderLocalPart.
fieldDefaultSenderLocalPart = defaultSenderLocalPart;
|
protected void | setMaxMessageSizeExceeded(java.lang.Boolean maxMessageSizeExceeded)Sets the maxMessageSizeExceeded.
fieldMaxMessageSizeExceeded = maxMessageSizeExceeded;
|
protected void | setMessageDeleted()Set the DELETED flag.
getMessageIn().setFlag(Flags.Flag.DELETED, true);
|
protected void | setMessageIn(javax.mail.internet.MimeMessage messageIn)Sets the messageIn.
fieldMessageIn = messageIn;
|
protected void | setMessageSeen()
// If the Seen flag is not handled by the folder
// allow a handler to do whatever it deems necessary
if (!getMessageIn()
.getFolder()
.getPermanentFlags()
.contains(Flags.Flag.SEEN))
handleMarkSeenNotPermanent();
else
getMessageIn().setFlag(Flags.Flag.SEEN, true);
|
protected void | setRecipientNotFound(boolean recipientNotFound)Sets the recipientNotFound.
fieldRecipientNotFound = recipientNotFound;
|
protected void | setRemoteAddress(java.lang.String remoteAddress)Sets the remoteAddress.
fieldRemoteAddress = remoteAddress;
|
protected void | setRemoteDomain(java.lang.String remoteDomain)Sets the remoteDomain.
fieldRemoteDomain = remoteDomain;
|
protected void | setRemoteHostName(java.lang.String remoteHostName)Sets the remoteHostName.
fieldRemoteHostName = remoteHostName;
|
protected void | setRemoteReceivedHeaderInvalid(java.lang.Boolean remoteReceivedHeaderInvalid)Sets the remoteReceivedHeaderInvalid.
fieldRemoteReceivedHeaderInvalid = remoteReceivedHeaderInvalid;
|
protected void | setRemoteRecipient(boolean localRecipient)Sets the localRecipient.
fieldRemoteRecipient = localRecipient;
|
protected void | setUserUndefined(boolean userUndefined)Sets the userUndefined.
fieldUserUndefined = userUndefined;
|
protected void | updateMaxMessageSizeExceeded()Refreshes the maxMessageSizeExceeded.
setMaxMessageSizeExceeded(computeMaxMessageSizeExceeded());
|
protected void | updateRemoteAddress()Updates the remoteAddress.
setRemoteAddress(computeRemoteAddress());
|
protected void | updateRemoteDomain()Updates the remoteDomain.
setRemoteDomain(computeRemoteDomain());
|
protected void | updateRemoteHostName()Updates the remoteHostName.
setRemoteHostName(computeRemoteHostName());
|
protected void | updateRemoteReceivedHeaderInvalid()Updates the remoteReceivedHeaderInvalid.
setRemoteReceivedHeaderInvalid(computeRemoteReceivedHeaderInvalid());
|