class MockSmtpServer
Attributes
buffer[R]
Public Class Methods
new(smtp_host, smtp_port)
click to toggle source
# File vendor/qwik/lib/qwik/mock-sendmail.rb, line 12 def initialize(smtp_host, smtp_port) @smtp_host, @smtp_port = smtp_host, smtp_port @buffer = [] @in_data = false end
open(smtp_host, smtp_port)
click to toggle source
# File vendor/qwik/lib/qwik/mock-sendmail.rb, line 8 def self.open(smtp_host, smtp_port) return self.new(smtp_host, smtp_port) end
Public Instance Methods
close()
click to toggle source
# File vendor/qwik/lib/qwik/mock-sendmail.rb, line 54 def close # Do nothing. end
gets()
click to toggle source
# File vendor/qwik/lib/qwik/mock-sendmail.rb, line 19 def gets if @buffer.empty? return '220 qwik.jp ESMTP MockSmtpServer' end if @in_data if /\.\z/ =~ @buffer.last @in_data = false return '250 Ok: queued as 381E41683E' # The message is fake. end end cmd = @buffer.last[0..3].downcase case cmd when 'ehlo' return '250 example.com' when 'mail' return '250 ok' when 'rcpt' return '250 ok' when 'data' @in_data = true return '354 End data with <CR><LF>.<CR><LF>' when 'quit' return '221 Bye' end return '' end
print(str)
click to toggle source
# File vendor/qwik/lib/qwik/mock-sendmail.rb, line 49 def print(str) str.sub!(/\r\n\z/, '') @buffer << str end