com.cometway.email
Class ReceiveEmailAgent

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.email.ReceiveEmailAgent
All Implemented Interfaces:
AgentInterface, HasStateMachineModel, java.lang.Runnable

public class ReceiveEmailAgent
extends Agent
implements java.lang.Runnable

This agent receives SMTP messages on a server socket (port 25 by default) and forwards them to RequestAgents registered to the Service Manager using the recipients email address (ie: name@domain) or email account name only (ie: name). On UNIX operating systems, root access is required to serve on port 25. You will also need to kill sendmail or any other SMTP servers that may already be using port 25. It may also be necessary to add a MX DNS entry for your server in order to allow SMTP messages to be routed properly to your server (read "DNS & BIND" from O'Reilly publishing more a good reference on DNS).


Field Summary
protected  java.util.Vector receivers
           
protected  java.lang.Object waitSync
           
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
ReceiveEmailAgent()
           
 
Method Summary
 void handleClient(java.net.Socket client)
          If the max_connections parameter has been not been exceeded, this method passes the socket connection to a ReceiveEmailHandler for further processing on its own Thread (owned by ESMTPReceiver).
 void initProps()
          Sets the default Props for this agent: "bind_port" is the port this agent opens to listen for SMTP connections, "max_connections" is the maximum number of simultaneous SMTP connections this agent allows.
 void returnHandler(ReceiveEmailHandler handler)
          This method is called when the ReceiveEmailHandler is no longer needed.
 void run()
          Opens a server socket on the bind_port and listens for SMTP connections.
 void start()
          Starts this agent by spawning a thread that listens for SMTP connections and passes them to REceiveEmailHandlers for further processing.
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, stop, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

receivers

protected java.util.Vector receivers

waitSync

protected java.lang.Object waitSync
Constructor Detail

ReceiveEmailAgent

public ReceiveEmailAgent()
Method Detail

initProps

public void initProps()
Sets the default Props for this agent: "bind_port" is the port this agent opens to listen for SMTP connections, "max_connections" is the maximum number of simultaneous SMTP connections this agent allows.

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

start

public void start()
Starts this agent by spawning a thread that listens for SMTP connections and passes them to REceiveEmailHandlers for further processing.

Specified by:
start in interface AgentInterface
Overrides:
start in class Agent

run

public void run()
Opens a server socket on the bind_port and listens for SMTP connections. New socket connections are passed to handleClient for further processing.

Specified by:
run in interface java.lang.Runnable

handleClient

public void handleClient(java.net.Socket client)
If the max_connections parameter has been not been exceeded, this method passes the socket connection to a ReceiveEmailHandler for further processing on its own Thread (owned by ESMTPReceiver).


returnHandler

public void returnHandler(ReceiveEmailHandler handler)
This method is called when the ReceiveEmailHandler is no longer needed.