IMAP: add options to move received emails.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2220 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
538bd7cd7f
commit
16eb0421e5
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -71,6 +71,11 @@ Issue attributes control options:
|
|||
allow_override=ATTRS allow email content to override attributes
|
||||
specified by previous options
|
||||
ATTRS is a comma separated list of attributes
|
||||
|
||||
Processed emails control options:
|
||||
move_on_success=MAILBOX move emails that were successfully received
|
||||
to MAILBOX instead of deleting them
|
||||
move_on_failure=MAILBOX move emails that were ignored to MAILBOX
|
||||
|
||||
Examples:
|
||||
# No project specified. Emails MUST contain the 'Project' keyword:
|
||||
|
@ -95,7 +100,9 @@ END_DESC
|
|||
:ssl => ENV['ssl'],
|
||||
:username => ENV['username'],
|
||||
:password => ENV['password'],
|
||||
:folder => ENV['folder']}
|
||||
:folder => ENV['folder'],
|
||||
:move_on_success => ENV['move_on_success'],
|
||||
:move_on_failure => ENV['move_on_failure']}
|
||||
|
||||
options = { :issue => {} }
|
||||
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
|
||||
|
|
Loading…
Reference in New Issue