atg.service.email.examiner
Class EximEmailExaminer

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.email.examiner.EmailExaminerImpl
              extended by atg.service.email.examiner.EximEmailExaminer
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, atg.service.email.examiner.AdditionalHeadersEmailExaminer, EmailExaminer, java.util.EventListener

public class EximEmailExaminer
extends atg.service.email.examiner.EmailExaminerImpl

This email examiner examines emails that are in Exim format


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.service.email.examiner.EmailExaminerImpl
mEmailTrackingTools, mExtractOriginalMessageIDFromMessageText, mScanningContentForAdditionalHeaders, X_ATG_HEADER_PREFIX
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
EximEmailExaminer()
           
 
Method Summary
 java.lang.Object examineEmail(javax.mail.Message pMessage)
          This method examines the given message in some implementation specific manner.
 java.lang.String getBouncedEmailAddress(javax.mail.Message pMessage)
          This method gets the email address from a presumed bounced email in sendmail format.
 java.lang.String getBouncedEnhancedStatusCode(javax.mail.Message pMessage)
          Gets the enhanced status code according to RFC 1893 that gives more detail on the nature of the error.
 java.lang.String getBouncedEnhancedStatusCode(java.lang.String pContent)
          Gets the enhanced status code from the given content, if any exists.
 java.lang.String getBouncedErrorMessage(javax.mail.Message pMessage)
          This method gets any associated error message that is given from a bounced email.
 java.lang.String getBouncedErrorMessage(java.lang.String pContent)
          Gets the error message for the given bounced email content It is assumed that the error message is after a triple dot in the same line that the reply code is present on.
 java.lang.String getBouncedReplyCode(javax.mail.Message pMessage)
          Gets the reply code (RFC 821) of the given bounced message.
 java.lang.String getBouncedReplyCode(java.lang.String pContent)
          Gets the reply code present in the given email content It's assumed that the reply code is present after the "]: " string in the given content
 boolean getConfiguredSoftBounceCodes(java.lang.String replyCode)
          Get the soft bounce reply codes from the configuration file
 java.lang.String[] getMonitoredBounceReplyCodes()
          Gets the MonitoredReplyCodes property
 boolean isBouncedEmail(javax.mail.Message pMessage)
          Determines whether the passed in message was bounced by an exim MTA.
 void setMonitoredBounceReplyCodes(java.lang.String[] pMonitoredBounceReplyCodes)
          Sets the MonitoredBounceReplyCodes property
 
Methods inherited from class atg.service.email.examiner.EmailExaminerImpl
getAdditionalHeaderPrefixes, getAdditionalHeaders, getEmailTrackingTools, getMTAName, getOriginalMessageID, getSoftBounceEnhancedStatusCodes, getSoftBounceReplyCodes, getTrackingData, isExtractOriginalMessageIDFromMessageText, isScanningContentForAdditionalHeaders, isSoftBouncedEmail, setAdditionalHeaderPrefixes, setEmailTrackingTools, setExtractOriginalMessageIDFromMessageText, setMTAName, setScanningContentForAdditionalHeaders, setSoftBounceEnhancedStatusCodes, setSoftBounceReplyCodes
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

EximEmailExaminer

public EximEmailExaminer()
Method Detail

setMonitoredBounceReplyCodes

public void setMonitoredBounceReplyCodes(java.lang.String[] pMonitoredBounceReplyCodes)
Sets the MonitoredBounceReplyCodes property

Parameters:
pMonitoredBounceReplyCodes - an array of RFC 821 reply codes that will indicate an email is bounced. The isBouncedEmail method will only return true if the reply code set in the bounced email matches one of the values of this property

getMonitoredBounceReplyCodes

public java.lang.String[] getMonitoredBounceReplyCodes()
Gets the MonitoredReplyCodes property

Returns:
an array of RFC 821 reply codes that will indicate an email is bounced. The isBouncedEmail method will only return true if the reply code set in the bounced email matches one of the values of this property

isBouncedEmail

public boolean isBouncedEmail(javax.mail.Message pMessage)
                       throws javax.mail.MessagingException,
                              EmailException
Determines whether the passed in message was bounced by an exim MTA. Exim is nice and sets a "X-Failed-Recipients" header if the message is bounced, so we simply check to see if that header is present. We also check that the reply code for any bounced email is present in the monitoredBounceReplyCodes property, if set.

Parameters:
pMessage - the message to examine
Returns:
true if the message is contains an "X-Failed-Recipients" header and has a reply code present in the monitoredBounceReplyCodes property if set, false otherwise
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the header, or if invalid arguments are specified

getConfiguredSoftBounceCodes

public boolean getConfiguredSoftBounceCodes(java.lang.String replyCode)
Get the soft bounce reply codes from the configuration file

Overrides:
getConfiguredSoftBounceCodes in class atg.service.email.examiner.EmailExaminerImpl
Parameters:
replyCode - the replyCode to examine
Returns:
true if the replyCode is found from the configured soft bounce code list, false otherwise

getBouncedEmailAddress

public java.lang.String getBouncedEmailAddress(javax.mail.Message pMessage)
                                        throws javax.mail.MessagingException,
                                               EmailException
This method gets the email address from a presumed bounced email in sendmail format. This implementation looks for the address in a specific location in the email's content Specifically: "<<< xxx x.x.x " where xxx is the reply code and x.x.x is the enhanced status code.

Parameters:
pMessage - the message to examine
Returns:
the email address of the intended recipient, or null if the message is not bounced, or is not in sendmail format
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the content, of invalid arguments are specified

getBouncedReplyCode

public java.lang.String getBouncedReplyCode(javax.mail.Message pMessage)
                                     throws javax.mail.MessagingException,
                                            EmailException
Gets the reply code (RFC 821) of the given bounced message. This reply code should exist in the getMonitoredBounceReplyCodes array. This implementation looks for the reply code after the sendmail session transcript line that starts with "<<< "

Parameters:
pMessage - the bounced message to examine
Returns:
the reply code of the bounced email, indicating why it was bounced, or null if the message cannot be determined from the give pMessage i.e. the formatting is not what was expected, or the message has not been determined as bounced
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the content, of invalid arguments are specified NOTE: An exception should NOT be thrown if the given message is not in a format recognized by this examiner. In most cases, a list of examiners will be called upon to see if any consider the message as bounced in a given operation. Developers are expected to return null in this case.

getBouncedErrorMessage

public java.lang.String getBouncedErrorMessage(javax.mail.Message pMessage)
                                        throws javax.mail.MessagingException,
                                               EmailException
This method gets any associated error message that is given from a bounced email. In sendmail, this is located typically after a "... " pattern in the line that indicates the message is bounced. For example: "<<< xxx x.x.x ... Error Message" where xxx is the reply code and x.x.x is the enhanced status code

Parameters:
pMessage - the message to examine
Returns:
the error message that indicates why the email was bounced or null if the email is not in sendmail format, or if there is no error message to get
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the content, of invalid arguments are specified

getBouncedEnhancedStatusCode

public java.lang.String getBouncedEnhancedStatusCode(javax.mail.Message pMessage)
                                              throws javax.mail.MessagingException,
                                                     EmailException
Gets the enhanced status code according to RFC 1893 that gives more detail on the nature of the error.

Parameters:
pMessage - the message to examine
Returns:
an enhanced status code of the bounced email, indicating why it was bounced, or null if the given message is not in sendmail format
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the content, of invalid arguments are specified

examineEmail

public java.lang.Object examineEmail(javax.mail.Message pMessage)
                              throws javax.mail.MessagingException,
                                     EmailException
This method examines the given message in some implementation specific manner. This implementation is a no-op

Parameters:
pMessage - the message to examine
Returns:
null
Throws:
javax.mail.MessagingException - if a problem occurs while calling methods on the pMessage object
EmailException - if a problem occurs during the parsing of the content, of invalid arguments are specified

getBouncedReplyCode

public java.lang.String getBouncedReplyCode(java.lang.String pContent)
Gets the reply code present in the given email content It's assumed that the reply code is present after the "]: " string in the given content

Parameters:
pContent - the content to examine
Returns:
the reply code contained in the given content

getBouncedErrorMessage

public java.lang.String getBouncedErrorMessage(java.lang.String pContent)
Gets the error message for the given bounced email content It is assumed that the error message is after a triple dot in the same line that the reply code is present on.

Parameters:
pContent - the email content to examine
Returns:
the error message indicating why the email was bounced, or null if none exists

getBouncedEnhancedStatusCode

public java.lang.String getBouncedEnhancedStatusCode(java.lang.String pContent)
Gets the enhanced status code from the given content, if any exists.

Parameters:
pContent - the content to parse
Returns:
the enhanced status code that is present in the content, or null if there is none