MailManager

A MailManager attempts to do everything that the client side of sendmail does - poorly.

Create an instance of a mail manager, and send messages to it. Then invoke processQueue(). The MailManager will take care of making sure that the messages get delivered, and storing them if they are not.

You may also use the spawnMailAgent(), waitOnMailAgent() and mailAgentFinished() methods to fork off the mail queue processing in another process.

Methods

__init__(self, mailqueue, debug)

   def __init__(self, mailqueue = '/var/MailManagerQueue', debug = 0):

Constructs a new instance using the given filename as the location for the mail queue.

If debug has the 1 bit set, activity during queue processing is written to standard output. If its 2 bit is set, Mailer debug mode is set (which displays all connection info).

enqueueMessage(self, msg)

   def enqueueMessage(self, msg):

Adds the given message (which should be an instance of EMailMessage) to the queue.

mailAgentFinished(self)

   def mailAgentFinished(self):

Returns true if a previously spawned mail agent has finished processing.

Since this uses the waitpid function, once it succeeds it can not be used again.

processQueue(self)

   def processQueue(self):

Walks through the mail queue and attempts to send each of the messages.

spawnMailAgent(self)

   def spawnMailAgent(self):

Forks and lets the child process process the queue. Obviously, the fork command must be supported.

waitOnMailAgent(self)

   def waitOnMailAgent(self):

Waits for a mail agent spawned with spawnMailAgent() to finish.

Since this uses the waitpid command, any subsequent attempts to use this after the initial wait will fail.

writeQueue(self)

   def writeQueue(self):

Writes the queue to the queue file.