-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing multiple RFC support (MAIL FROM + RCPT TO) #367
Comments
If I understand correctly https://www.rfc-editor.org/rfc/rfc4954#section-5
Since |
Still early, but it seems the following fixes the issue related to async def handle_EHLO(self, server, session, envelope, hostname, response):
"""
EHLO handler intended to remove the '250-AUTH' line from the response since we do not use
any authentication.
"""
session.host_name = hostname
return [r for r in response if not r.startswith("250-AUTH")] But of course it only works if clients properly implement the RFC. |
I though about something like this (to allow override the SMTP class methods): diff --git a/aiosmtpd/smtp.py b/aiosmtpd/smtp.py
index a977f75..41bdf70 100644
--- a/aiosmtpd/smtp.py
+++ b/aiosmtpd/smtp.py
@@ -1225,6 +1225,10 @@ class SMTP(asyncio.StreamReaderProtocol):
else:
await self.push('501 Syntax: VRFY <address>')
+ def mail_cmd_params(self, params):
+ """Handle extra parameters for MAIL smtp command"""
+ return
+
@syntax('MAIL FROM: <address>', extended=' [SP <mail-parameters>]')
async def smtp_MAIL(self, arg: str) -> None:
if await self.check_helo_needed():
@@ -1281,7 +1285,8 @@ class SMTP(asyncio.StreamReaderProtocol):
'552 Error: message size exceeds fixed maximum message '
'size')
return
- if len(params) > 0:
+ r = self.mail_cmd_params(params)
+ if r or len(params) > 0:
await self.push(
'555 MAIL FROM parameters not recognized or not implemented')
return
@@ -1293,6 +1298,10 @@ class SMTP(asyncio.StreamReaderProtocol):
log.info('%r sender: %s', self.session.peer, address)
await self.push(status)
+ def rcpt_cmd_params(self, params):
+ """Handle extra parameters for RCPT smtp command"""
+ return
+
@syntax('RCPT TO: <address>', extended=' [SP <mail-parameters>]')
async def smtp_RCPT(self, arg: str) -> None:
if await self.check_helo_needed():
@@ -1321,8 +1330,8 @@ class SMTP(asyncio.StreamReaderProtocol):
params = self._getparams(rcpt_options)
if params is None:
return await self.push(syntaxerr)
- # XXX currently there are no options we recognize.
- if len(params) > 0:
+ r = self.rcpt_cmd_params(params)
+ if r or len(params) > 0:
return await self.push(
'555 RCPT TO parameters not recognized or not implemented'
) |
I'm using this diff in my local smtp server which works as a proxy for the postfix. The aiosmtpd does not understand some parameters for MAIL FROM and RCPT TO:
It would be nice, if someone can add those extensions. Also, it may be nice to have a list of parameters to be skipped in the SMTP class, so users can add the extra parameters to the class (using own class or assignments) without the need to modify directly the base class.
EDIT: v2 - added NOTIFY parameter
The text was updated successfully, but these errors were encountered: