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.
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).
Adds the given message (which should be an instance of EMailMessage) to the queue.
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.
Walks through the mail queue and attempts to send each of the messages.
Forks and lets the child process process the queue. Obviously, the fork
command must be supported.
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.
Writes the queue to the queue file.
enqueueMessage(self, msg)
def enqueueMessage(self, msg):
mailAgentFinished(self)
def mailAgentFinished(self):
processQueue(self)
def processQueue(self):
spawnMailAgent(self)
def spawnMailAgent(self):
waitOnMailAgent(self)
def waitOnMailAgent(self):
writeQueue(self)
def writeQueue(self):