Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 56b36ae

Browse files
committed
Update docs
1 parent a5a77de commit 56b36ae

6 files changed

Lines changed: 61 additions & 14 deletions

File tree

docs/getting_started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ By deafult, all configuration happens in ``config/``
102102
^^^^^^^^^^^
103103

104104
This file is used by Salmon during start-up to configure the daemon with
105-
various things, such as starting the ``LMTPReceiver``. It's a bit like the
105+
various things, such as starting the ``AsyncLMTPReceiver``. It's a bit like the
106106
``wsgi.py`` file that Python web apps have. If you want to use a different boot
107107
module, you can specify it with the ``--boot`` argument. E.g. to use
108108
``myapp/othermodule.py``, do:
@@ -144,18 +144,18 @@ much in the same way as you host a WSGI application behind Apache or Nginx.
144144

145145
As seen above, a new Salmon project will start a LMTP server that listens on
146146
``localhost:8823``. You can go into ``config/settings.py`` and change the host
147-
and port Salmon uses. You can also switch out ``LMTPReceiver`` for
148-
``SMTPReceiver`` if you require Salmon to use SMTP instead.
147+
and port Salmon uses. You can also switch out ``AsyncLMTPReceiver`` for
148+
``AsyncSMTPReceiver`` if you require Salmon to use SMTP instead.
149149

150150
.. warning::
151151

152152
Due to the way Salmon has been implemented it is better suited as a LMTP
153-
server than a SMTP server. ``SMTPReceiver`` is unable to handle multiple
153+
server than a SMTP server. ``AsyncSMTPReceiver`` is unable to handle multiple
154154
recipients in one transaction as it doesn't implement the nessessary
155155
features to properly implement this part of the SMTP protocol. This is a
156-
compromise ``SMTPReceiver`` makes in order to allow users more freedom in
156+
compromise ``AsyncSMTPReceiver`` makes in order to allow users more freedom in
157157
what they do in their handlers.
158158

159159

160-
``LMTPReceiver`` is unaffected by this issue and implements the LMTP
160+
``AsyncLMTPReceiver`` is unaffected by this issue and implements the LMTP
161161
protocol fully.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Contents:
2020
routing
2121
relaying
2222
mail_objects
23+
receivers
2324
commandline
2425
Salmon API guide <salmon>
2526

docs/receivers.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Receivers
2+
=========
3+
4+
Salmon comes with a number of receivers
5+
6+
Asyncio based receivers
7+
-----------------------
8+
9+
Salmon's default receivers based on `aiosmtpd <https://github.com/aio-libs/aiosmtpd>`__.
10+
11+
.. note::
12+
Although these receivers use Asyncio, your handlers are executed in a
13+
separate thread to allow them to use synchronous code that is easier to
14+
write and maintain.
15+
16+
:class:`~salmon.server.AsyncLMTPReceiver`
17+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
:class:`~salmon.server.AsyncSMTPReceiver`
20+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
22+
Asyncore based receivers
23+
------------------------
24+
25+
Salmon's original receivers based on Python's ``smtpd`` library.
26+
27+
:class:`~salmon.server.LMTPReceiver`
28+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
30+
:class:`~salmon.server.SMTPReceiver`
31+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
33+
.. warning::
34+
This receiver is not suitable for use on an Internet facing port. Try
35+
`AsyncSMTPReceiver`_ instead.
36+
37+
Other receivers
38+
---------------
39+
40+
:class:`~salmon.server.QueueReceiver`
41+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

salmon/data/prototype/config/boot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from salmon import queue
44
from salmon.routing import Router
5-
from salmon.server import LMTPReceiver, Relay
5+
from salmon.server import AsyncLMTPReceiver, Relay
66

77
from . import settings
88

@@ -13,8 +13,8 @@
1313
port=settings.relay_config['port'], debug=1)
1414

1515
# where to listen for incoming messages
16-
settings.receiver = LMTPReceiver(settings.receiver_config['host'],
17-
settings.receiver_config['port'])
16+
settings.receiver = AsyncLMTPReceiver(hostname=settings.receiver_config['host'],
17+
port=settings.receiver_config['port'])
1818

1919
Router.defaults(**settings.router_defaults)
2020
Router.load(settings.handlers)

salmon/server.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ def _deliver(receiver, Peer, From, To, Data, **kwargs):
175175

176176

177177
class SMTPChannel(smtpd.SMTPChannel):
178-
"""Replaces the standard SMTPChannel with one that rejects more than one recipient"""
179-
180178
def smtp_RCPT(self, arg):
181179
if self.__rcpttos:
182180
# We can't properly handle multiple RCPT TOs in SMTPReceiver
@@ -202,7 +200,11 @@ def smtp_RCPT(self, arg):
202200

203201

204202
class SMTPReceiver(smtpd.SMTPServer):
205-
"""Receives emails and hands it to the Router for further processing."""
203+
"""Receives emails and hands it to the Router for further processing.
204+
205+
206+
This Receiver is based on Python's asyncore module. Consider using AsyncSMTPReceiver.
207+
"""
206208

207209
def __init__(self, host='127.0.0.1', port=8825):
208210
"""
@@ -245,7 +247,10 @@ def process_message(self, Peer, From, To, Data, **kwargs):
245247

246248

247249
class LMTPReceiver(lmtpd.LMTPServer):
248-
"""Receives emails and hands it to the Router for further processing."""
250+
"""Receives emails and hands it to the Router for further processing.
251+
252+
This Receiver is based on Python's asyncore module. Consider using AsyncLMTPReceiver.
253+
"""
249254

250255
def __init__(self, host='127.0.0.1', port=8824, socket=None):
251256
"""

salmon/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def make_fake_settings(host, port):
9494
logging.basicConfig(filename="logs/logger.log", level=logging.DEBUG)
9595
routing.Router.load(['salmon.handlers.log', 'salmon.handlers.queue'])
9696
settings = imp.new_module('settings')
97-
settings.receiver = server.SMTPReceiver(host, port)
97+
settings.receiver = server.AsyncSMTPReceiver(hostname=host, port=port)
9898
settings.relay = None
9999
logging.info("Logging mode enabled, will not send email to anyone, just log.")
100100

0 commit comments

Comments
 (0)