Package lamson :: Module server :: Class Relay
[hide private]
[frames] | no frames]

Class Relay

source code


Used to talk to your "relay server" or smart host, this is probably the most important class in the handlers next to the lamson.routing.Router. It supports a few simple operations for sending mail, replying, and can log the protocol it uses to stderr if you set debug=1 on __init__.

Instance Methods [hide private]
 
__init__(self, host='127.0.0.1', port=25, username=None, password=None, ssl=False, starttls=False, debug=0)
The hostname and port we're connecting to, and the debug level (default to 0).
source code
 
configure_relay(self, hostname) source code
 
deliver(self, message, To=None, From=None)
Takes a fully formed email message and delivers it to the configured relay server.
source code
 
resolve_relay_host(self, To) source code
 
__repr__(self)
Used in logging and debugging to indicate where this relay goes.
source code
 
reply(self, original, From, Subject, Body)
Calls self.send but with the from and to of the original message reversed.
source code
 
send(self, To, From, Subject, Body)
Does what it says, sends an email.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, host='127.0.0.1', port=25, username=None, password=None, ssl=False, starttls=False, debug=0)
(Constructor)

source code 

The hostname and port we're connecting to, and the debug level (default to 0). Optional username and password for smtp authentication. If ssl is True smtplib.SMTP_SSL will be used. If starttls is True (and ssl False), smtp connection will be put in TLS mode. It does the hard work of delivering messages to the relay host.

Overrides: object.__init__

configure_relay(self, hostname)

source code 

deliver(self, message, To=None, From=None)

source code 

Takes a fully formed email message and delivers it to the configured relay server.

You can pass in an alternate To and From, which will be used in the SMTP send lines rather than what's in the message.

resolve_relay_host(self, To)

source code 

__repr__(self)
(Representation operator)

source code 

Used in logging and debugging to indicate where this relay goes.

Overrides: object.__repr__

reply(self, original, From, Subject, Body)

source code 

Calls self.send but with the from and to of the original message reversed.

send(self, To, From, Subject, Body)

source code 

Does what it says, sends an email. If you need something more complex then look at lamson.mail.MailResponse.