Project

General

Profile

Actions

Patch #2420

closed

Fetching emails from an POP server

Added by Alex Popov almost 16 years ago. Updated almost 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Email receiving
Target version:
Start date:
2008-12-30
Due date:
% Done:

0%

Estimated time:

Description

This is a patch to fetch emails from POP server instead of IMAP (based on IMAP handling code)

Copy attahced pop3.rb into lib\redmine directory

require 'net/pop'

module Redmine
  module POP3
    class << self
      def check(pop_options={}, options={})
        host = pop_options[:host] || '127.0.0.1'
        port = pop_options[:port] || '110'

        pop = Net::POP3.new(host,port)
        pop.start(pop_options[:username], pop_options[:password]) do |pop_session|
          pop_session.each_mail do |msg|
            message = msg.pop
            logger.debug "Receiving message: #{message.grep(/^Subject: /)}" if logger && logger.debug?
            if MailHandler.receive(message, options)
              logger.info "Message #{message.grep(/^Subject: /)} processed -- removing from server." if logger && logger.info?
              puts "#{message.grep(/^Subject: /)}" 
              puts "--> Message processed and deleted from the server" 
              msg.delete
            else
              puts "#{message.grep(/^Subject: /)}" 
              puts "--> Message NOT processed -- leaving it on the server" 
              logger.info "ERROR: Message #{message.grep(/^Subject: /)} can not be processed, leaving on the server." if logger && logger.info?
            end

          end
        end

      end

      private

      def logger
        RAILS_DEFAULT_LOGGER
      end
    end
  end
end

and add the new task to email.rake file in lib\tasks

    task :receive_pop => :environment do
      pop_options  = {:host => ENV['host'],
                      :port => ENV['port'],
                      :username => ENV['username'],
                      :password => ENV['password']}

      options = { :issue => {} }
      %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
      options[:allow_override] = ENV['allow_override'] if ENV['allow_override']

      Redmine::POP3.check(pop_options, options)
    end

Files

email.rake (4.82 KB) email.rake modified email.rake file (lib\tasks) Alex Popov, 2008-12-30 23:59
pop3.rb (2.07 KB) pop3.rb new pop3.rb file (place into lib\redmine) Alex Popov, 2008-12-30 23:59
Actions #1

Updated by Chaoqun Zou over 15 years ago

+1

Actions #2

Updated by dct abuyz over 15 years ago

this helps to fetch emails also from apop

lib/redmine/pop3.rb

module Redmine
  module POP3
    class << self
      def check(pop_options={}, options={})
        host = pop_options[:host] || '127.0.0.1'
        port = pop_options[:port] || '110'
+       apop = pop_potions[:apop] || false

-       pop = Net::POP3.new(host,port)
+        pop = Net::POP3.APOP(apop).new(host,port)

...

lib/tasks/email.rake

    task :receive_pop => :environment do
      pop_options  = {:host => ENV['host'],
                      :port => ENV['port'],
+                     :apop => ENV['apop'],
                      :username => ENV['username'],
                      :password => ENV['password']}

      options = { :issue => {} }
      %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
      options[:allow_override] = ENV['allow_override'] if ENV['allow_override']

      Redmine::POP3.check(pop_options, options)
    end

Actions #3

Updated by Jean-Philippe Lang almost 15 years ago

  • Category changed from Email notifications to Email receiving
Actions #4

Updated by Mélanie Gault almost 15 years ago

very interested for this functionality too!

Actions #5

Updated by Jeffrey Jones almost 15 years ago

Definite +1 for this issue to be rolled into the core. My company only allows POP3 accounts for some reason so this is essential

Actions #6

Updated by Jean-Philippe Lang almost 15 years ago

  • Status changed from New to Closed
  • Target version set to 1.0.0 (RC)

Feature added in r3330.

Actions

Also available in: Atom PDF