Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #351 from jonasschneider/smtp-add-reset-after-sent…

…-mail

Fix SMTP server behaviour to reset mail transaction state after sending message
  • Loading branch information...
commit 3535f3aa2da005eae6a31c9202b6c427589d20a3 2 parents 7a44d7c + 5c07d82
@tmm1 tmm1 authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/em/protocols/smtpserver.rb
View
15 lib/em/protocols/smtpserver.rb
@@ -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.
#
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.