Class: BBMB::Util::PopMission
- Inherits:
-
Object
- Object
- BBMB::Util::PopMission
- Defined in:
- lib/bbmb/util/polling_manager.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def content_type @content_type end |
#host ⇒ Object
Returns the value of attribute host.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def host @host end |
#pass ⇒ Object
Returns the value of attribute pass.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def pass @pass end |
#port ⇒ Object
Returns the value of attribute port.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def user @user end |
Instance Method Details
#poll(&block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bbmb/util/polling_manager.rb', line 48 def poll(&block) # puts "PopMission starts polling host #{@host}:#{@port} u: #{@user} pw: #{@pass}" @backup_dir ||= Dir.tmpdir = { :address => @host, :port => @port, :user_name => @user, :password => @pass, :enable_ssl => true } ::Mail.defaults do retriever_method :pop3, end all_mails = ::Mail.delivery_method.is_a?(::Mail::TestMailer) ? ::Mail::TestMailer.deliveries : ::Mail.all all_mails.each do |mail| begin (mail, &block) ensure time = Time.now name = sprintf("%s.%s.%s", @user, time.strftime("%Y%m%d%H%M%S"), time.usec) FileUtils.mkdir_p(@backup_dir) path = File.join(@backup_dir, name) File.open(path, 'w') { |fh| fh.puts(mail) } mail.mark_for_delete = true # mail.delete # Not necessary with gem mail, as delete_after_find is set to true by default end end end |
#poll_message(message, &block) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/bbmb/util/polling_manager.rb', line 75 def (, &block) if(.multipart?) .parts.each do |part| (part, &block) end elsif(/text\/xml/.match(.content_type)) filtered_transaction(.decoded, sprintf('pop3:%s@%s:%s', @user, @host, @port), &block) end end |