examples/test2.rb
def receive(local_port, local_hostname, remote_port, remote_hostname, remote_ip)
    send("220 mail.example.com ESMTP");

    done = false
    tls_started = false
    while !done
      text = recv
      case
      when text.start_with?("QUIT")
        send("221 2.0.0 OK mail.example.com closing connection")
        break;
      when text.start_with?("EHLO")
        send("250-2.0.0 mail.example.com Hello")
        send("250-STARTTLS") if !tls_started
        send("250 HELP")
      when text.start_with?("STARTTLS")
        send("220 TLS go ahead")
        @connection.accept
        tls_started = true
      when text.start_with?("MAIL")
        send("250 OK")
      when text.start_with?("RCPT")
        send("250 OK")
      when text.start_with?("DATA")
        send("354 Enter message, ending with \".\" on a line by itself")
        while text.chomp!='.'
          text = recv
        end
        send("250 OK id=123456-654321-99")
      end
    end
  end
# don't use this as an example of how to write
# an email receiver--it's just a simplified demo
don't use this as an example of how to write
an email receiver--it's just a simplified demo
don ' t use this as an example of how to write an email receiver -- it ' s just a simplified demo
def receive(local_port, local_hostname, remote_port, remote_hostname, remote_ip)
    send("220 mail.example.com ESMTP");
    done = false
    tls_started = false
    while !done
      text = recv
      case
      when text.start_with?("QUIT")
        send("221 2.0.0 OK mail.example.com closing connection")
        break;
      when text.start_with?("EHLO")
        send("250-2.0.0 mail.example.com Hello")
        send("250-STARTTLS") if !tls_started
        send("250 HELP")
      when text.start_with?("STARTTLS")
        send("220 TLS go ahead")
        @connection.accept
        tls_started = true
      when text.start_with?("MAIL")
        send("250 OK")
      when text.start_with?("RCPT")
        send("250 OK")
      when text.start_with?("DATA")
        send("354 Enter message, ending with \".\" on a line by itself")
        while text.chomp!='.'
          text = recv
        end
        send("250 OK id=123456-654321-99")
      end
    end
  end
def receive ( local_port , local_hostname , remote_port , remote_hostname , remote_ip ) send ( "220 mail.example.com ESMTP" ) ; done = false tls_started = false while ! done text = recv case when text . start_with? ( "QUIT" ) send ( "221 2.0.0 OK mail.example.com closing connection" ) break ; when text . start_with? ( "EHLO" ) send ( "250-2.0.0 mail.example.com Hello" ) send ( "250-STARTTLS" ) if ! tls_started send ( "250 HELP" ) when text . start_with? ( "STARTTLS" ) send ( "220 TLS go ahead" ) @connection . accept tls_started = true when text . start_with? ( "MAIL" ) send ( "250 OK" ) when text . start_with? ( "RCPT" ) send ( "250 OK" ) when text . start_with? ( "DATA" ) send ( "354 Enter message, ending with \".\" on a line by itself" ) while text . chomp != '.' text = recv end send ( "250 OK id=123456-654321-99" ) end end end
don't use this as an example of how to write
an email receiver--it's just a simplified demo
don ' t use this as an example of how to write an email receiver -- it ' s just a simplified demo
local_port
local_hostname
remote_port
remote_hostname
remote_ip