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

Allow custom EHLO after RSET again #270

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

sapmli
Copy link
Contributor

@sapmli sapmli commented Sep 2, 2024

conn.go Outdated
if c.session != nil {
// RFC 5321: "If it is issued after the session begins
// and the EHLO command is acceptable to the SMTP server, ..."
if !c.fromReceived {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't quite get why this condition is here. Why do we need to skip reset() when the client has sent MAIL FROM?

Copy link
Contributor Author

@sapmli sapmli Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what I found in the connection that may be usable for the condition "if it is issued after the session begins".
If I interprete the RFC correctly, then only in this case, EHLO acts like RSET.
It's not stated what should happen if it's issued not at the start of the session (or not after a RSET), though.

Maybe we can find out by examining some example sequences

EHLO // <-- session begins (no buffers and tables to be cleared anyway)
MAIL FROM
RCPT TO
DATA
RSET

EHLO // <-- redundant to previous RSET, but allowed
MAIL FROM
RCPT TO
EHLO // <-- should have not RSET effect
DATA // should then probably be okay (from, rcpt tables still there)
RSET

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Session begins" just means that a TCP connection is opened no?

Copy link
Contributor Author

@sapmli sapmli Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intersting question. If so, then do you think that an EHLO after RSET should not be passed to the session as Reset()? Then I wonder how the session would become aware of the new EHLO argument.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that we should probably always call c.reset(), even in the case where MAIL FROM was sent by the client (that's what fromReceived means).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I can do that. I'll update the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But feel free to adapt it to your likings and code style etc.

@emersion emersion force-pushed the fix/ehlo-after-rset branch from a56e6c2 to 2a51e89 Compare September 7, 2024 10:53
@emersion emersion enabled auto-merge (rebase) September 7, 2024 10:53
@emersion emersion disabled auto-merge September 7, 2024 10:54
Copy link
Owner

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I've re-organized the changes into two commits.

@emersion emersion merged commit c6c3019 into emersion:master Sep 7, 2024
1 check passed
@sapmli sapmli deleted the fix/ehlo-after-rset branch September 9, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EHLO after RSET
2 participants