Skip to content
This repository
Browse code

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
Aman Gupta authored February 27, 2013

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  lib/em/protocols/smtpserver.rb
15  lib/em/protocols/smtpserver.rb
@@ -506,11 +506,13 @@ def process_rcpt_to rcpt
506 506
       # Since we clear the chunk array every time we submit it, the caller needs to be
507 507
       # aware to do things like dup it if he wants to keep it around across calls.
508 508
       #
509  
-      # DON'T reset the transaction upon disposition of the incoming message.
510  
-      # This means another DATA command can be accepted with the same sender and recipients.
511  
-      # If the client wants to reset, he can call RSET.
512  
-      # Not sure whether the standard requires a transaction-reset at this point, but it
513  
-      # appears not to.
  509
+      # Resets the transaction upon disposition of the incoming message.
  510
+      # RFC5321 says this about the MAIL FROM command:
  511
+      #  "This command tells the SMTP-receiver that a new mail transaction is
  512
+      #   starting and to reset all its state tables and buffers, including any
  513
+      #   recipients or mail data."
  514
+      #
  515
+      # Equivalent behaviour is implemented by resetting after a completed transaction.
514 516
       #
515 517
       # User-written code can return a Deferrable as a response from receive_message.
516 518
       #
@@ -524,11 +526,12 @@ def process_data_line ln
524 526
 
525 527
           succeeded = proc {
526 528
             send_data "250 Message accepted\r\n"
  529
+            reset_protocol_state
527 530
           }
528 531
           failed = proc {
529 532
             send_data "550 Message rejected\r\n"
  533
+            reset_protocol_state
530 534
           }
531  
-
532 535
           d = receive_message
533 536
 
534 537
           if d.respond_to?(:set_deferred_status)

0 notes on commit 3535f3a

Please sign in to comment.
Something went wrong with that request. Please try again.