Welcome to gsmtpd’s documentation!¶
gsmtpd server¶
gsmtpd is a SMTP server implement based on Gevent library, better in conccurence and more API
Example
from gevent import monkey
monkey.patch_all()
from gsmtpd.server import SMTPServer
class PrintSMTPServer(SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
print data
print_server = PrintSMTPServer()
print_server.serve_forever()
Contents:
gsmtpd.server¶
An RFC 2821 smtp proxy server port from Python Standrad Library for Gevent usage
- class gsmtpd.server.SMTPServer(localaddr=None, remoteaddr=None, timeout=60, data_size_limit=10240000, **kwargs)[source]¶
Abstrcted SMTP server
- __init__(localaddr=None, remoteaddr=None, timeout=60, data_size_limit=10240000, **kwargs)[source]¶
Initialize SMTP Server
Parameters: - localaddr – tuple pair that start server, like (‘127.0.0.1’, 25)
- remoteaddr – ip address (string or list) that can relay on this server
- timeout – int that connection Timeout
- data_size_limit – max byte per mail data
- kwargs – other key-arguments will pass to SSLSettings
- process_message(peer, mailfrom, rcpttos, data)[source]¶
Override this abstract method to handle messages from the client.
Parameters: - peer –
is a tuple containing (ipaddr, port) of the client that made
the socket connection to our smtp port.
- mailfrom – is the raw address the client claims the message is coming from.
- rcpttos – is a list of raw addresses the client wishes to deliver the message to.
- data –
is a string containing the entire full text of the message,
headers (if supplied) and all. It has been `de-transparencied’
according to RFC 821, Section 4.5.2.
In other words, a line containing a `.’ followed by other text has had the leading dot
removed.
This function should return None, for a normal `250 Ok’ response; otherwise it returns the desired response string in RFC 821 format.
- peer –
- process_rcpt(address)[source]¶
Override this abstract method to handle rcpt from the client
Parameters: address – is raw address the client wishes to deliver the message to This function should return None, for a normal `250 Ok’ response; otherwise it returns the desired response string in RFC 821 format.
- class gsmtpd.server.SSLSettings(keyfile=None, certfile=None, ssl_version='PROTOCOL_SSLv23', ca_certs=None, do_handshake_on_connect=True, cert_reqs=0, suppress_ragged_eofs=True, ciphers=None, **kwargs)[source]¶
SSL settings object
- __init__(keyfile=None, certfile=None, ssl_version='PROTOCOL_SSLv23', ca_certs=None, do_handshake_on_connect=True, cert_reqs=0, suppress_ragged_eofs=True, ciphers=None, **kwargs)[source]¶
settings of SSL
Parameters: - keyfile – SSL key file path usally end with ”.key”
- certfile – SSL cert file path usally end with ”.crt”