Skip to content

Instantly share code, notes, and snippets.

@rnaveiras
Created June 26, 2009 11:56
Show Gist options
  • Save rnaveiras/136438 to your computer and use it in GitHub Desktop.
Save rnaveiras/136438 to your computer and use it in GitHub Desktop.
require 'net/pop'
require File.dirname(__FILE__) + '/../config/environment'
logger = RAILS_DEFAULT_LOGGER
logger.info "Running Mail Importer..."
Net::POP3.start("mail.server.net", nil, "username", "password") do |pop|
if pop.mails.empty?
logger.info "NO MAIL"
else
pop.mails.each do |email|
begin
logger.info "receiving mail..."
Mailman.receive(TMail::Mail.parse(email.pop))
email.delete
rescue Exception => e
logger.error e.message
end
end
end
end
logger.info "Finished Mail Importer."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment