SHARE
TWEET

Untitled

a guest Dec 3rd, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## /script/dropbox_receiver.rb
  2.  
  3.  
  4.  
  5. require 'net/pop'
  6. require 'rubygems'
  7.  
  8.  
  9. #DROPBOXES = %w{dropbo dropbo1}
  10. DROPBOXES = %w{sellam2}
  11.  
  12.  
  13. logger = RAILS_DEFAULT_LOGGER
  14.  
  15.  
  16. logger.info "Running Mail Importer..."
  17.  
  18. DROPBOXES.each do |dropbox|
  19.     Net::POP3.start("pop-1.mail.vi.net", nil, dropbox, "iguana") do |pop|
  20.       if pop.mails.empty?
  21.         logger.info "NO MAIL"
  22.       else
  23.         pop.mails.each do |email|
  24.           begin
  25.             logger.info "receiving mail..."
  26.                     raise email.pop.class.inspect
  27.             DropBoxMailer.receive(email.pop)
  28.             email.delete
  29.           rescue Exception => e
  30.             logger.error "Error receiving email at " + Time.now.to_s + "::: " + e.message
  31.           end
  32.         end
  33.       end
  34.     end
  35. end
  36. logger.info "Finished Mail Importer."
  37.  
  38.  
  39.  
  40. ## /app/mailers/drob_box_mailer.rb
  41.  
  42.  
  43.  
  44. class DropBoxMailer < ActionMailer::Base
  45.  
  46.   def receive(email)
  47.     @email = email
  48.   end  
  49. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top