Skip to content
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

aiosmtpd rejects unknown parameters in MAIL FROM #98

Open
scottydawg1 opened this issue Jan 4, 2024 · 8 comments
Open

aiosmtpd rejects unknown parameters in MAIL FROM #98

scottydawg1 opened this issue Jan 4, 2024 · 8 comments
Assignees
Labels
bug Something isn't working needs-integration-test

Comments

@scottydawg1
Copy link

I am struggling to get one of my systems in my homelab to work. vCenter seems to be passing AUTH=<> as part of the message and mailrise is rejecting the email and returning it sender.

while talking to [IP address]:
MAIL From:discord@mailrise.xyz SIZE=1459 AUTH=<>
<<< 555 MAIL FROM parameters not recognized or not implemented
554 5.0.0 Service unavailable

Not sure if this is a bug or not

@YoRyan
Copy link
Owner

YoRyan commented Jan 4, 2024

This is a known upstream issue with aiosmtpd, the SMTP library that Mailrise is using (aio-libs/aiosmtpd#299). I've implemented the workaround identified in that thread. Try the new image (7cdfe27) and see if that resolves this for you.

@YoRyan YoRyan self-assigned this Jan 4, 2024
@YoRyan YoRyan added the bug Something isn't working label Jan 4, 2024
@scottydawg1
Copy link
Author

Confirmed, that work around fixed it. Thanks!

@YoRyan
Copy link
Owner

YoRyan commented Jan 5, 2024

Awesome! Glad it worked.

@YoRyan YoRyan closed this as completed Jan 5, 2024
@YoRyan
Copy link
Owner

YoRyan commented Jan 9, 2024

Reverting this fix because it breaks SMTP authentication.

Unfortunately, I don’t think there’s a way to fix this from Mailrise’s end. It’s aiosmtpd that’s refusing the messages.

@YoRyan YoRyan reopened this Jan 9, 2024
@YoRyan YoRyan changed the title parameters not recognized or not implemented aiosmtpd rejects unknown parameters in MAIL FROM Jan 9, 2024
@scottydawg1
Copy link
Author

Fair enough. I am perfectly fine with not updating my version as have no need for authentication. Thank you!

@YoRyan
Copy link
Owner

YoRyan commented Jan 9, 2024

Even better: With 76e6162, the workaround will only be applied when not using SMTP authentication. 😉

I’ll keep this issue open because we really should just ignore all unknown parameters as soon as aiosmtpd lets us do that.

@Salvoxia
Copy link

Hi,

the new handle_EHLO hook added with 76e6162 seems to cause an SMTP session exception in aiosmtpd if SMTP authentication is used:

[2024-01-14 18:27:29] INFO:mailrise.skeleton:Loaded configuration with 12 recipient(s)
[2024-01-14 18:27:29] INFO:mailrise.skeleton:TLS enabled and successfully initialized
[2024-01-14 18:27:29] DEBUG:mailrise.skeleton:Arguments for aiosmtpd: authenticator=Basic(9), auth_required=True, auth_require_tls=True, tls_context=<ssl.SSLContext object at 0x7f5d6287d2d0>, ssl_context=None, require_starttls=False
[2024-01-14 18:27:29] DEBUG:asyncio:Using selector: EpollSelector
[2024-01-14 18:28:57] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2024-01-14 18:28:57] INFO:mail.log:Peer: ('192.168.1.5', 46656)
[2024-01-14 18:28:57] INFO:mail.log:('192.168.1.5', 46656) handling connection
[2024-01-14 18:28:57] DEBUG:mail.log:('192.168.1.5', 46656) << b'220 mailrise.mydomain.com Mailrise 0.0.post1.dev1+g76e6162'
[2024-01-14 18:28:57] DEBUG:mail.log:_handle_client readline: b'ehlo internalclient\r\n'
[2024-01-14 18:28:57] INFO:mail.log:('192.168.1.5', 46656) >> b'ehlo internalclient'
[2024-01-14 18:28:57] ERROR:mail.log:('192.168.1.5', 46656) SMTP session exception
Traceback (most recent call last):
  File "/home/mailrise/.local/lib/python3.12/site-packages/aiosmtpd/smtp.py", line 741, in _handle_client
    await method(arg)
  File "/home/mailrise/.local/lib/python3.12/site-packages/aiosmtpd/smtp.py", line 865, in smtp_EHLO
    for r in response:
TypeError: 'NoneType' object is not iterable
[2024-01-14 18:28:57] DEBUG:mail.log:('192.168.1.5', 46656) << b"500 Error: (TypeError) 'NoneType' object is not iterable"

The hook does not seem to return anything if SMTP auth is used, but aiosmtpd replaces the response sent to EHLO with what the hook returns and expects it to be an iterable: https://github.com/aio-libs/aiosmtpd/blob/83168cdc057d9d63b6f212f330fafecb4fbfe662/aiosmtpd/smtp.py#L863-L866

I guess if SMTP authentication is used the hook should simply return the response that was passed to it as-is.

Best Regards,
Salvoxia

@YoRyan
Copy link
Owner

YoRyan commented Jan 14, 2024

Thanks. Reverting until I have integration tests for all of the SMTP authentication functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-integration-test
Projects
None yet
Development

No branches or pull requests

3 participants