Method: Net::POP3.foreach
- Defined in:
- lib/net/pop.rb
.foreach(address, port = nil, account = nil, password = nil, isapop = false, &block) ⇒ Object
Starts a POP3 session and iterates over each POPMail object, yielding it to the block. This method is equivalent to:
Net::POP3.start(address, port, account, password) do |pop|
pop.each_mail do |m|
yield m
end
end
This method raises a POPAuthenticationError if authentication fails.
Example
Net::POP3.foreach('pop.example.com', 110,
'YourAccount', 'YourPassword') do |m|
file.write m.pop
m.delete if $DELETE
end
263 264 265 266 267 268 269 |
# File 'lib/net/pop.rb', line 263 def POP3.foreach(address, port = nil, account = nil, password = nil, isapop = false, &block) # :yields: message start(address, port, account, password, isapop) {|pop| pop.each_mail(&block) } end |