Module: Commands::Definitions

Included in:
SMTP::Session
Defined in:
lib/drillmail/commands/definitions.rb

Instance Method Summary collapse

Instance Method Details

#commandsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/drillmail/commands/definitions.rb', line 4

def commands
  {
    HELO: self.respond_to?(:hello) ? self.method(:hello) : proc { reply(502) },
    EHLO: self.respond_to?(:extended_hello) ? self.method(:extended_hello) : proc { reply (502) },
    MAIL: self.respond_to?(:mail) ? self.method(:mail) : proc { reply(502) },
    RCPT: self.respond_to?(:recipient) ? self.method(:recipient) : proc { reply(502) },
    DATA: self.respond_to?(:data) ? self.method(:data) : proc { reply(502) },
    SEND: self.respond_to?(:send) ? self.method(:send) : proc { reply(502) },
    SOML: self.respond_to?(:send_or_mail) ? self.method(:send_or_mail) : proc { reply(502) },
    SAML: self.respond_to?(:send_and_mail) ? self.method(:send_and_mail) : proc { reply(502) },
    RSET: self.respond_to?(:reset) ? self.method(:reset) : proc { reply(502) },
    VRFY: self.respond_to?(:verify) ? self.method(:verify) : proc { reply(502) },
    EXPN: self.respond_to?(:expand) ? self.method(:expand) : proc { reply(502) },
    HELP: self.respond_to?(:help) ? self.method(:help) : proc { reply(502) },
    NOOP: self.respond_to?(:no_operation) ? self.method(:no_operation) : proc { reply(502) },
    QUIT: self.respond_to?(:quit) ? self.method(:quit) : proc { reply(502) },
    TURN: self.respond_to?(:turn) ? self.method(:turn) : proc { reply(502) }
  }
end

#repliesObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/drillmail/commands/definitions.rb', line 28

def replies
  {
    211 => "System status",
    214 => "Help message",
    # weird issue where only 220 needs a \r\n
    220 => "%{message} service ready\r\n",
    221 => "%{message} service closing transmission tunnel",
    250 => "%{message} OK",
    251 => "User not local; will forward to %{message}",
    354 => "Start mail input; end with <CLRF>.<CLRF>",
    421 => "%{message} service not available, closing transmission tunnel",
    450 => "Requested mail action not taken: mailbox unavailable",
    451 => "Requested action aborted: local error in processing",
    452 => "Requested action not taken: insufficient system storage",
    500 => "Syntax error, command not recognized",
    501 => "Syntax error in paramters or arguments",
    502 => "Command not implemented",
    503 => "Bad sequence of commands",
    504 => "Command parameter not implemented",
    550 => "Requested action not taken: mailbox unavailable %{message}",
    551 => "User not local; please try %{message}",
    552 => "Requested mail action aborted: exceeded storage allocation",
    553 => "Requested action not taken: mailbox name not allowed",
    554 => "Transaction Failed"
  }
end

#reply(number, message = '') ⇒ Object



24
25
26
# File 'lib/drillmail/commands/definitions.rb', line 24

def reply(number, message='')
  "#{number} #{replies[number] % { message: message }}"
end