class EventMachine::Protocols::SmtpServer

def process_data_line ln


User-written code can return a Deferrable as a response from receive_message.

Equivalent behaviour is implemented by resetting after a completed transaction.

recipients or mail data."
starting and to reset all its state tables and buffers, including any
"This command tells the SMTP-receiver that a new mail transaction is
RFC5321 says this about the MAIL FROM command:
Resets the transaction upon disposition of the incoming message.

aware to do things like dup it if he wants to keep it around across calls.
Since we clear the chunk array every time we submit it, the caller needs to be
storing to disk, etc.
one line at a time. That lets the application be a little more flexible about
Send the incoming data to the application one chunk at a time, rather than
def process_data_line ln
  if ln == "."
    if @databuffer.length > 0
      receive_data_chunk @databuffer
      @databuffer.clear
    end
    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)
      d.callback(&succeeded)
      d.errback(&failed)
    else
      (d ? succeeded : failed).call
    end
    @state.delete :data
  else
    # slice off leading . if any
    ln.slice!(0...1) if ln[0] == ?.
    @databuffer << ln
    if @databuffer.length > @@parms[:chunksize]
      receive_data_chunk @databuffer
      @databuffer.clear
    end
  end
end