Skip to content

Commit

Permalink
fix: apply workaround for clients that send mail from auth=<>, but on…
Browse files Browse the repository at this point in the history
…ly when not using authentication
  • Loading branch information
YoRyan committed Jan 14, 2024
1 parent ee40be5 commit 3fb4a57
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/mailrise/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ async def handle_DATA(self, server: SMTP, session: Session, envelope: Envelope)

return '250 OK'

# pylint: disable=invalid-name,unused-argument
async def handle_EHLO(self, _server: SMTP, session: Session, _envelope: Envelope,
hostname: str, responses: list[str]) -> list[str]:
"""This hook is called during ``EHLO``."""
if not self.config.authenticator:
# Workaround for SMTP clients that send MAIL FROM AUTH=<>
# It only works if we're not using SMTP authentication.
# https://github.com/aio-libs/aiosmtpd/issues/299#issuecomment-1427487291
session.host_name = hostname # type: ignore
return [r for r in responses if not r.startswith("250-AUTH")]
else:
return responses


def _parsemessage(msg: StdlibEmailMessage, envelope: Envelope) -> r.EmailMessage:
"""Parses an email message into an `EmailNotification`.
Expand Down

0 comments on commit 3fb4a57

Please sign in to comment.