blob: ebb0b302d226a303a89a994de7dc460f5ca918a2 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001:mod:`smtpd` --- SMTP Server
2============================
3
4.. module:: smtpd
5 :synopsis: A SMTP server implementation in Python.
6
7.. moduleauthor:: Barry Warsaw <barry@zope.com>
8.. sectionauthor:: Moshe Zadka <moshez@moshez.org>
9
Éric Araujo29a0b572011-08-19 02:14:03 +020010**Source code:** :source:`Lib/smtpd.py`
Georg Brandl8ec7f652007-08-15 14:28:01 +000011
Éric Araujo29a0b572011-08-19 02:14:03 +020012--------------
Georg Brandl8ec7f652007-08-15 14:28:01 +000013
14This module offers several classes to implement SMTP servers. One is a generic
15do-nothing implementation, which can be overridden, while the other two offer
16specific mail-sending strategies.
17
18
19SMTPServer Objects
20------------------
21
22
23.. class:: SMTPServer(localaddr, remoteaddr)
24
25 Create a new :class:`SMTPServer` object, which binds to local address
26 *localaddr*. It will treat *remoteaddr* as an upstream SMTP relayer. It
27 inherits from :class:`asyncore.dispatcher`, and so will insert itself into
28 :mod:`asyncore`'s event loop on instantiation.
29
30
Benjamin Petersonc7b05922008-04-25 01:29:10 +000031 .. method:: process_message(peer, mailfrom, rcpttos, data)
Georg Brandl8ec7f652007-08-15 14:28:01 +000032
Benjamin Petersonc7b05922008-04-25 01:29:10 +000033 Raise :exc:`NotImplementedError` exception. Override this in subclasses to
34 do something useful with this message. Whatever was passed in the
35 constructor as *remoteaddr* will be available as the :attr:`_remoteaddr`
36 attribute. *peer* is the remote host's address, *mailfrom* is the envelope
37 originator, *rcpttos* are the envelope recipients and *data* is a string
38 containing the contents of the e-mail (which should be in :rfc:`2822`
39 format).
Georg Brandl8ec7f652007-08-15 14:28:01 +000040
41
42DebuggingServer Objects
43-----------------------
44
45
46.. class:: DebuggingServer(localaddr, remoteaddr)
47
48 Create a new debugging server. Arguments are as per :class:`SMTPServer`.
49 Messages will be discarded, and printed on stdout.
50
51
52PureProxy Objects
53-----------------
54
55
56.. class:: PureProxy(localaddr, remoteaddr)
57
58 Create a new pure proxy server. Arguments are as per :class:`SMTPServer`.
59 Everything will be relayed to *remoteaddr*. Note that running this has a good
60 chance to make you into an open relay, so please be careful.
61
62
63MailmanProxy Objects
64--------------------
65
66
67.. class:: MailmanProxy(localaddr, remoteaddr)
68
69 Create a new pure proxy server. Arguments are as per :class:`SMTPServer`.
70 Everything will be relayed to *remoteaddr*, unless local mailman configurations
71 knows about an address, in which case it will be handled via mailman. Note that
72 running this has a good chance to make you into an open relay, so please be
73 careful.
74