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

Fix SMTP server behaviour to reset mail transaction state after sending message #351

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/em/protocols/smtpserver.rb
Expand Up @@ -506,11 +506,13 @@ def process_rcpt_to rcpt
# Since we clear the chunk array every time we submit it, the caller needs to be
# aware to do things like dup it if he wants to keep it around across calls.
#
# DON'T reset the transaction upon disposition of the incoming message.
# This means another DATA command can be accepted with the same sender and recipients.
# If the client wants to reset, he can call RSET.
# Not sure whether the standard requires a transaction-reset at this point, but it
# appears not to.
# Resets the transaction upon disposition of the incoming message.
# RFC5321 says this about the MAIL FROM command:
# "This command tells the SMTP-receiver that a new mail transaction is
# starting and to reset all its state tables and buffers, including any
# recipients or mail data."
#
# Equivalent behaviour is implemented by resetting after a completed transaction.
#
# User-written code can return a Deferrable as a response from receive_message.
#
Expand All @@ -524,11 +526,12 @@ def process_data_line ln

succeeded = proc {
send_data "250 Message accepted\r\n"
reset_protocol_state
}
failed = proc {
send_data "550 Message rejected\r\n"
reset_protocol_state
}

d = receive_message

if d.respond_to?(:set_deferred_status)
Expand Down