| |
- exceptions.Exception(exceptions.BaseException)
-
- net.sendmail.MalformedEMailAddress
- net.sendmail.UnexpectedResponse
- net.sendmail.EMailAddress
- net.sendmail.EMailMessage
- net.sendmail.MailManager
- net.sendmail.Mailer
class EMailAddress |
|
Contains an e-mail address.
Public variables:
/login/::
User login name.
/host/::
`TCP/IP` host name.
/fullName/::
Full name of the user. |
|
Methods defined here:
- __init__(self, login, host, fullName='')
- asAddress(self)
- Returns the e-mail address formatted as user@hostname.
- asHeader(self)
- Returns the e-mail address formatted in a manner suitable for a
header line: "Full Name <user@hostname>". If /fullName/ is
an empty string, the user login is substituted for the full name.
- getHandlerAddresses(self)
- Returns the mail handler host addresses for the e-mail domain.
- setHandlerAddresses(self, addrs)
- Used to set the mail handler host addresses for the e-mail domain.
|
class EMailMessage |
|
Sort of like an RFC822 message, only not limited to its file
structure.
Public variables:
/fromAddr/::
The source @EMailAddress.
/toAddr/::
A list of destination @EMailAddress instances.
/date/::
The date that the message was constructed as a UNIX time value.
/subject/::
Message subject.
/cc/::
A list of cc @EMailAddress instances.
/bcc/::
A list of bcc @EMailAddress instances.
/body/::
A string representing the body of the message.
XXX should probably store its complete string representation so we
don't have to render it every time that we process the queue. |
|
Methods defined here:
- __init__(self, fromAddr, toAddrs, date, subject, body, cc=[], bcc=[])
- Constructor. /fromAddr/ is an both instances of @EMailAddress,
/date/ should be a UNIX time value. /subject/ should be a string.
/body/ should also be a string (and may contain newlines). /cc/,
/bcc/, and /toAddrs/ should both be a list of @EMailAddress
instances.
- deliveredTo(self, addr)
- This method is used to indicate that the message has been delivered
to the given address. The address will be removed from the list
of addresses that it must be delivered to.
- getDeliveryList(self)
- Returns the list of addresses that the message must still be
delivered to sorted by host. Note that this list is the same list
that is used internally, so the caller should not attempt to modify
it.
- writeTo(self, out)
- Writes the message onto the given output stream /out/.
|
class 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 defined here:
- __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)
- Adds the given message (which should be an instance of
@EMailMessage) to the queue.
- 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)
- Walks through the mail queue and attempts to send each of the
messages.
- spawnMailAgent(self)
- Forks and lets the child process process the queue. Obviously,
the fork command must be supported.
- 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)
- Writes the queue to the queue file.
|
class Mailer |
|
A *Mailer* manages a connection to a single sendmail daemon. |
|
Methods defined here:
- __init__(self, host, debug=0)
- Constructs a new Mailer object, creating a connection to the
specified host. /host/ should be a string specifying either a
dotted ip address or a host name.
if /debug/ is true, all sends and receives are printed.
- readline(self)
- Returns the next `CR/LF` or LF terminated line from the server.
This is normally for internal use only.
- send(self, data)
- Sends /data/ (a string) to the mail daemon at the other end.
This is normally for internal use only.
- sendMessage(self, fromUser, toUser, messageBody)
- Sends the message in the /messageBody/ string to the user identified
by /toUser/. /toUser/ and /fromUser/ should both be instances of
@EMailAddress.
- waitFor(self, code)
- Waits for a particular 3 character code from the server, discards
all 220's that are returned.
- waitFor220(self)
- Waits for a 220 line from the server.
This is normally for internal use only.
Data and other attributes defined here:
- ipRx = r'\d+\.\d+\.\d+\.\d+'
|
|