| 1 |
:mod:`smtpd` --- SMTP Server |
| 2 |
============================ |
| 3 |
|
| 4 |
.. module:: smtpd |
| 5 |
:synopsis: A SMTP server implementation in Python. |
| 6 |
|
| 7 |
.. moduleauthor:: Barry Warsaw <[email protected]> |
| 8 |
.. sectionauthor:: Moshe Zadka <[email protected]> |
| 9 |
|
| 10 |
**Source code:** :source:`Lib/smtpd.py` |
| 11 |
|
| 12 |
-------------- |
| 13 |
|
| 14 |
This module offers several classes to implement SMTP servers. One is a generic |
| 15 |
do-nothing implementation, which can be overridden, while the other two offer |
| 16 |
specific mail-sending strategies. |
| 17 |
|
| 18 |
|
| 19 |
SMTPServer 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. Both |
| 27 |
*localaddr* and *remoteaddr* should be a :ref:`(host, port) <host_port>` |
| 28 |
tuple. The object inherits from :class:`asyncore.dispatcher`, and so will |
| 29 |
insert itself into :mod:`asyncore`'s event loop on instantiation. |
| 30 |
|
| 31 |
|
| 32 |
.. method:: process_message(peer, mailfrom, rcpttos, data) |
| 33 |
|
| 34 |
Raise :exc:`NotImplementedError` exception. Override this in subclasses to |
| 35 |
do something useful with this message. Whatever was passed in the |
| 36 |
constructor as *remoteaddr* will be available as the :attr:`_remoteaddr` |
| 37 |
attribute. *peer* is the remote host's address, *mailfrom* is the envelope |
| 38 |
originator, *rcpttos* are the envelope recipients and *data* is a string |
| 39 |
containing the contents of the e-mail (which should be in :rfc:`2822` |
| 40 |
format). |
| 41 |
|
| 42 |
|
| 43 |
DebuggingServer Objects |
| 44 |
----------------------- |
| 45 |
|
| 46 |
|
| 47 |
.. class:: DebuggingServer(localaddr, remoteaddr) |
| 48 |
|
| 49 |
Create a new debugging server. Arguments are as per :class:`SMTPServer`. |
| 50 |
Messages will be discarded, and printed on stdout. |
| 51 |
|
| 52 |
|
| 53 |
PureProxy Objects |
| 54 |
----------------- |
| 55 |
|
| 56 |
|
| 57 |
.. class:: PureProxy(localaddr, remoteaddr) |
| 58 |
|
| 59 |
Create a new pure proxy server. Arguments are as per :class:`SMTPServer`. |
| 60 |
Everything will be relayed to *remoteaddr*. Note that running this has a good |
| 61 |
chance to make you into an open relay, so please be careful. |
| 62 |
|
| 63 |
|
| 64 |
MailmanProxy Objects |
| 65 |
-------------------- |
| 66 |
|
| 67 |
|
| 68 |
.. class:: MailmanProxy(localaddr, remoteaddr) |
| 69 |
|
| 70 |
Create a new pure proxy server. Arguments are as per :class:`SMTPServer`. |
| 71 |
Everything will be relayed to *remoteaddr*, unless local mailman configurations |
| 72 |
knows about an address, in which case it will be handled via mailman. Note that |
| 73 |
running this has a good chance to make you into an open relay, so please be |
| 74 |
careful. |
| 75 |
|