Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## /script/dropbox_receiver.rb
- require 'net/pop'
- require 'rubygems'
- #DROPBOXES = %w{dropbo dropbo1}
- DROPBOXES = %w{sellam2}
- logger = RAILS_DEFAULT_LOGGER
- logger.info "Running Mail Importer..."
- DROPBOXES.each do |dropbox|
- Net::POP3.start("pop-1.mail.vi.net", nil, dropbox, "iguana") do |pop|
- if pop.mails.empty?
- logger.info "NO MAIL"
- else
- pop.mails.each do |email|
- begin
- logger.info "receiving mail..."
- raise email.pop.class.inspect
- DropBoxMailer.receive(email.pop)
- email.delete
- rescue Exception => e
- logger.error "Error receiving email at " + Time.now.to_s + "::: " + e.message
- end
- end
- end
- end
- end
- logger.info "Finished Mail Importer."
- ## /app/mailers/drob_box_mailer.rb
- class DropBoxMailer < ActionMailer::Base
- def receive(email)
- @email = email
- end
- end
Add Comment
Please, Sign In to add comment