Class: Hermeneutics::Cli::LMTP
Defined Under Namespace
Classes: NotOk, NotReadyForData, Response, ServerNotReady, Uncaught, UnspecError, Unused
Constant Summary
collapse
- CRLF =
true
Instance Attribute Summary collapse
Attributes inherited from Protocol
#timeout
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Protocol
#done?, #read, #readline, #trace!, #wait, #write, #writeline
Constructor Details
#initialize(*args) ⇒ LMTP
Returns a new instance of LMTP.
36
37
38
39
40
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 36
def initialize *args
super
get_response.ok? or raise ServerNotReady, @last_response.msg
@rcpt = 0
end
|
Instance Attribute Details
#advertised ⇒ Object
Returns the value of attribute advertised.
33
34
35
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 33
def advertised
@advertised
end
|
#domain ⇒ Object
Returns the value of attribute domain.
32
33
34
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 32
def domain
@domain
end
|
#greet ⇒ Object
Returns the value of attribute greet.
32
33
34
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 32
def greet
@greet
end
|
#last_response ⇒ Object
Returns the value of attribute last_response.
34
35
36
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 34
def last_response
@last_response
end
|
Class Method Details
.open(socketfile) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 24
def open socketfile
UNIXSocket.open socketfile do |s|
i = new s, nil
yield i
end
end
|
Instance Method Details
#bdat(data) ⇒ Object
89
90
91
92
93
94
95
96
97
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 89
def bdat data
data.each { |d|
write_cmd "BDAT", d.bytesize
write d
get_response_ok
}
write_cmd "BDAT", 0, "LAST"
get_response_rcpts
end
|
#data(reader) ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 78
def data reader
write_cmd "DATA"
get_response.waiting? or raise NotReadyForData, @last_response.msg
reader.each_line { |l|
l =~ /\A\./ and l = ".#{l}"
writeline l
}
writeline "."
get_response_rcpts
end
|
#lhlo(host = nil) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 47
def lhlo host = nil
@advertised = {}
write_cmd "LHLO", host||Socket.gethostname
get_response_ok do |code,msg|
unless @domain then
@domain, @greet = msg.split nil, 2
next
end
keyword, param = msg.split nil, 2
keyword.upcase!
keyword = keyword.to_sym
case keyword
when :SIZE then param = Integer param
when :AUTH then param = param.split.map { |p| p.upcase! ; p.to_sym }
end
@advertised[ keyword] = param || true
end
unless @domain then
@domain, @greet = @last_response.msg.split nil, 2
end
end
|
#mail_from(from) ⇒ Object
69
70
71
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 69
def mail_from from
cmd "MAIL", "FROM:<#{from}>"
end
|
#noop(str = nil) ⇒ Object
105
106
107
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 105
def noop str = nil
cmd "NOOP"
end
|
#quit ⇒ Object
109
110
111
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 109
def quit
cmd "QUIT"
end
|
#rcpt_to(to) ⇒ Object
73
74
75
76
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 73
def rcpt_to to
cmd "RCPT", "TO:<#{to}>"
@rcpt += 1
end
|
#rset ⇒ Object
99
100
101
102
103
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 99
def rset
cmd "RSET"
ensure
@rcpt = 0
end
|
#size ⇒ Object
42
43
44
|
# File 'lib/hermeneutics/cli/lmtp.rb', line 42
def size
@advertised && @advertised[ :SIZE]
end
|