]> source.dussan.org Git - redmine.git/commitdiff
IMAP: add options to move received emails.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 31 Dec 2008 14:56:30 +0000 (14:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 31 Dec 2008 14:56:30 +0000 (14:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2220 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/imap.rb
lib/tasks/email.rake

index a6cd958cdcca6cc559e6a3c62b430cb83ac70625..383d82f2318e6fe2e5c0cd97dc449e3213f5b2f5 100644 (file)
@@ -1,4 +1,4 @@
-# redMine - project management software
+# Redmine - project management software
 # Copyright (C) 2006-2008  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
@@ -33,9 +33,18 @@ module Redmine
           msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
           logger.debug "Receiving message #{message_id}" if logger && logger.debug?
           if MailHandler.receive(msg, options)
+            logger.debug "Message #{message_id} successfully received" if logger && logger.debug?
+            if imap_options[:move_on_success]
+              imap.copy(message_id, imap_options[:move_on_success])
+            end
             imap.store(message_id, "+FLAGS", [:Seen, :Deleted])
           else
+            logger.debug "Message #{message_id} can not be processed" if logger && logger.debug?
             imap.store(message_id, "+FLAGS", [:Seen])
+            if imap_options[:move_on_failure]
+              imap.copy(message_id, imap_options[:move_on_failure])
+              imap.store(message_id, "+FLAGS", [:Deleted])
+            end
           end
         end
         imap.expunge
index 30101cab7772714843a3908aea2db8a3086eba58..0f74d6bd36edc46920860a3db9310a3743374c33 100644 (file)
@@ -1,4 +1,4 @@
-# redMine - project management software\r
+# Redmine - project management software\r
 # Copyright (C) 2006-2008  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
@@ -71,6 +71,11 @@ Issue attributes control options:
   allow_override=ATTRS     allow email content to override attributes\r
                            specified by previous options\r
                            ATTRS is a comma separated list of attributes\r
+                           \r
+Processed emails control options:\r
+  move_on_success=MAILBOX  move emails that were successfully received\r
+                           to MAILBOX instead of deleting them\r
+  move_on_failure=MAILBOX  move emails that were ignored to MAILBOX\r
   \r
 Examples:\r
   # No project specified. Emails MUST contain the 'Project' keyword:\r
@@ -95,7 +100,9 @@ END_DESC
                       :ssl => ENV['ssl'],\r
                       :username => ENV['username'],\r
                       :password => ENV['password'],\r
-                      :folder => ENV['folder']}\r
+                      :folder => ENV['folder'],\r
+                      :move_on_success => ENV['move_on_success'],\r
+                      :move_on_failure => ENV['move_on_failure']}\r
                       \r
       options = { :issue => {} }\r
       %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }\r