Class: SMTPD
- Inherits:
-
Object
- Object
- SMTPD
- Defined in:
- lib/smtpserver.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#data_each_line ⇒ Object
writeonly
Sets the attribute data_each_line.
-
#data_hook ⇒ Object
writeonly
Sets the attribute data_hook.
-
#error_interval ⇒ Object
Returns the value of attribute error_interval.
-
#helo_hook ⇒ Object
writeonly
Sets the attribute helo_hook.
-
#input_timeout ⇒ Object
Returns the value of attribute input_timeout.
-
#line_length_limit ⇒ Object
Returns the value of attribute line_length_limit.
-
#mail_hook ⇒ Object
writeonly
Sets the attribute mail_hook.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#noop_hook ⇒ Object
writeonly
Sets the attribute noop_hook.
-
#quit_hook ⇒ Object
writeonly
Sets the attribute quit_hook.
-
#rcpt_hook ⇒ Object
writeonly
Sets the attribute rcpt_hook.
-
#rset_hook ⇒ Object
writeonly
Sets the attribute rset_hook.
-
#use_file ⇒ Object
Returns the value of attribute use_file.
Instance Method Summary collapse
-
#initialize(sock, domain) ⇒ SMTPD
constructor
A new instance of SMTPD.
- #start ⇒ Object
Constructor Details
#initialize(sock, domain) ⇒ SMTPD
Returns a new instance of SMTPD.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/smtpserver.rb', line 37 def initialize(sock, domain) @sock = sock @domain = domain @error_interval = 5 class << @sock include GetsSafe end @helo_hook = nil @mail_hook = nil @rcpt_hook = nil @data_hook = nil @data_each_line = nil @rset_hook = nil @noop_hook = nil @quit_hook = nil end |
Instance Attribute Details
#data_each_line=(value) ⇒ Object (writeonly)
Sets the attribute data_each_line
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def data_each_line=(value) @data_each_line = value end |
#data_hook=(value) ⇒ Object (writeonly)
Sets the attribute data_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def data_hook=(value) @data_hook = value end |
#error_interval ⇒ Object
Returns the value of attribute error_interval.
93 94 95 |
# File 'lib/smtpserver.rb', line 93 def error_interval @error_interval end |
#helo_hook=(value) ⇒ Object (writeonly)
Sets the attribute helo_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def helo_hook=(value) @helo_hook = value end |
#input_timeout ⇒ Object
Returns the value of attribute input_timeout.
92 93 94 |
# File 'lib/smtpserver.rb', line 92 def input_timeout @input_timeout end |
#line_length_limit ⇒ Object
Returns the value of attribute line_length_limit.
92 93 94 |
# File 'lib/smtpserver.rb', line 92 def line_length_limit @line_length_limit end |
#mail_hook=(value) ⇒ Object (writeonly)
Sets the attribute mail_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def mail_hook=(value) @mail_hook = value end |
#max_size ⇒ Object
Returns the value of attribute max_size.
94 95 96 |
# File 'lib/smtpserver.rb', line 94 def max_size @max_size end |
#noop_hook=(value) ⇒ Object (writeonly)
Sets the attribute noop_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def noop_hook=(value) @noop_hook = value end |
#quit_hook=(value) ⇒ Object (writeonly)
Sets the attribute quit_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def quit_hook=(value) @quit_hook = value end |
#rcpt_hook=(value) ⇒ Object (writeonly)
Sets the attribute rcpt_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def rcpt_hook=(value) @rcpt_hook = value end |
#rset_hook=(value) ⇒ Object (writeonly)
Sets the attribute rset_hook
53 54 55 |
# File 'lib/smtpserver.rb', line 53 def rset_hook=(value) @rset_hook = value end |
#use_file ⇒ Object
Returns the value of attribute use_file.
94 95 96 |
# File 'lib/smtpserver.rb', line 94 def use_file @use_file end |
Instance Method Details
#start ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/smtpserver.rb', line 56 def start @helo_name = nil @sender = nil @recipients = [] catch(:close) do puts_safe "220 #{@domain} service ready" while comm = @sock.gets_safe do catch :next_comm do comm.sub!(/\r?\n/, '') comm, arg = comm.split(/\s+/,2) break if comm == nil case comm.upcase when 'EHLO' then comm_helo arg when 'HELO' then comm_helo arg when 'MAIL' then comm_mail arg when 'RCPT' then comm_rcpt arg when 'DATA' then comm_data arg when 'RSET' then comm_rset arg when 'NOOP' then comm_noop arg when 'QUIT' then comm_quit arg else error '502 Error: command not implemented' end end end end end |