Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"command": "/usr/local/bin/python",
"args": [
"-m",
"smtpd",
"aiosmtpd",
"-n",
"-c",
"DebuggingServer",
"ietf.utils.aiosmtpd.DevDebuggingHandler",
"-l",
"localhost:2025"
],
"presentation": {
Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/app-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ echo "Running initial checks..."

if [ -z "$EDITOR_VSCODE" ]; then
CODE=0
python -m smtpd -n -c DebuggingServer localhost:2025 &
python -m aiosmtpd -n -c ietf.utils.aiosmtpd.DevDebuggingHandler -l localhost:2025 &
if [ -z "$*" ]; then
echo "-----------------------------------------------------------------"
echo "Ready!"
Expand Down
21 changes: 19 additions & 2 deletions ietf/utils/test_smtpserver.py → ietf/utils/aiosmtpd.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Copyright The IETF Trust 2014-2025, All Rights Reserved
# -*- coding: utf-8 -*-
"""aiosmtpd-related utilities

These are for testing / dev use. If you're using this for production code, think very
hard about the choices you're making...
"""
from aiosmtpd import handlers
from aiosmtpd.controller import Controller
from aiosmtpd.smtp import SMTP
from email.utils import parseaddr
from typing import Optional
from typing import Optional, TextIO


class SMTPTestHandler:
Expand Down Expand Up @@ -54,3 +58,16 @@ def start(self):

def stop(self):
self.controller.stop()


class DevDebuggingHandler(handlers.Debugging):
"""Debugging handler for use in dev ONLY"""
def __init__(self, stream: Optional[TextIO] = None):
# Allow longer lines than the 1001 that RFC 5321 requires. As of 2025-04-16 the
# datatracker emits some non-compliant messages.
# See https://aiosmtpd.aio-libs.org/en/latest/smtp.html
# Doing this in a handler class is a huge hack. Tests all pass with this set
# to 4000, but make the limit longer for dev just in case.
SMTP.line_length_limit = 10000
super().__init__(stream)

2 changes: 1 addition & 1 deletion ietf/utils/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import ietf
import ietf.utils.mail
from ietf.utils.management.commands import pyflakes
from ietf.utils.test_smtpserver import SMTPTestServerDriver
from ietf.utils.aiosmtpd import SMTPTestServerDriver
from ietf.utils.test_utils import TestCase

from mypy_boto3_s3.service_resource import Bucket
Expand Down