fake_smtp 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/fake_smtp/server.rb +7 -3
- data/lib/fake_smtp/version.rb +1 -1
- metadata +1 -1
data/lib/fake_smtp/server.rb
CHANGED
@@ -36,12 +36,12 @@ module FakeSmtp
|
|
36
36
|
def run
|
37
37
|
log("New session: #{@socket}")
|
38
38
|
|
39
|
-
handlers[:start]
|
39
|
+
instance_eval &handlers[:start] if handlers[:start]
|
40
40
|
until done
|
41
41
|
break unless cmd = read_line
|
42
42
|
handle_command cmd
|
43
43
|
end
|
44
|
-
handlers[:end]
|
44
|
+
instance_eval &handlers[:end] if handlers[:end]
|
45
45
|
|
46
46
|
@socket.close
|
47
47
|
log("Session finished: #{@socket}")
|
@@ -63,6 +63,7 @@ module FakeSmtp
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def respond_with(msg)
|
66
|
+
log "Response: #{msg}"
|
66
67
|
@socket.puts msg
|
67
68
|
end
|
68
69
|
|
@@ -75,9 +76,12 @@ module FakeSmtp
|
|
75
76
|
end
|
76
77
|
|
77
78
|
class SmtpSession < Session
|
79
|
+
on :start do
|
80
|
+
respond_with '220 smtp.example.com SMTP FakeSmtp'
|
81
|
+
end
|
78
82
|
on /^HELO|^EHLO/ do
|
79
83
|
words = cmd.split(' ')
|
80
|
-
respond_with "Hello #{words[1]} I am glad to meet you"
|
84
|
+
respond_with "250: Hello #{words[1]} I am glad to meet you"
|
81
85
|
end
|
82
86
|
|
83
87
|
on /^QUIT/ do
|
data/lib/fake_smtp/version.rb
CHANGED