Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
moggers87 committed Jul 12, 2020
1 parent 258730b commit 480cbe8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ By deafult, all configuration happens in ``config/``
^^^^^^^^^^^

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

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

.. warning::

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


``LMTPReceiver`` is unaffected by this issue and implements the LMTP
``AsyncLMTPReceiver`` is unaffected by this issue and implements the LMTP
protocol fully.
6 changes: 3 additions & 3 deletions salmon/data/prototype/config/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from salmon import queue
from salmon.routing import Router
from salmon.server import LMTPReceiver, Relay
from salmon.server import AsyncLMTPReceiver, Relay

from . import settings

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

# where to listen for incoming messages
settings.receiver = LMTPReceiver(settings.receiver_config['host'],
settings.receiver_config['port'])
settings.receiver = AsyncLMTPReceiver(hostname=settings.receiver_config['host'],
port=settings.receiver_config['port'])

Router.defaults(**settings.router_defaults)
Router.load(settings.handlers)
Expand Down
13 changes: 9 additions & 4 deletions salmon/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ def _deliver(receiver, Peer, From, To, Data, **kwargs):


class SMTPChannel(smtpd.SMTPChannel):
"""Replaces the standard SMTPChannel with one that rejects more than one recipient"""

def smtp_RCPT(self, arg):
if self.__rcpttos:
# We can't properly handle multiple RCPT TOs in SMTPReceiver
Expand All @@ -202,7 +200,11 @@ def smtp_RCPT(self, arg):


class SMTPReceiver(smtpd.SMTPServer):
"""Receives emails and hands it to the Router for further processing."""
"""Receives emails and hands it to the Router for further processing.
This Receiver is based on Python's asyncore module. Consider using AsyncSMTPReceiver.
"""

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


class LMTPReceiver(lmtpd.LMTPServer):
"""Receives emails and hands it to the Router for further processing."""
"""Receives emails and hands it to the Router for further processing.
This Receiver is based on Python's asyncore module. Consider using AsyncLMTPReceiver.
"""

def __init__(self, host='127.0.0.1', port=8824, socket=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion salmon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def make_fake_settings(host, port):
logging.basicConfig(filename="logs/logger.log", level=logging.DEBUG)
routing.Router.load(['salmon.handlers.log', 'salmon.handlers.queue'])
settings = imp.new_module('settings')
settings.receiver = server.SMTPReceiver(host, port)
settings.receiver = server.AsyncSMTPReceiver(hostname=host, port=port)
settings.relay = None
logging.info("Logging mode enabled, will not send email to anyone, just log.")

Expand Down

0 comments on commit 480cbe8

Please sign in to comment.