##// END OF EJS Templates
IMAP: add options to move received emails....
Jean-Philippe Lang -
r2218:16eb0421e5ac
parent child
Show More
@@ -1,4 +1,4
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
@@ -33,9 +33,18 module Redmine
33 msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
33 msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
34 logger.debug "Receiving message #{message_id}" if logger && logger.debug?
34 logger.debug "Receiving message #{message_id}" if logger && logger.debug?
35 if MailHandler.receive(msg, options)
35 if MailHandler.receive(msg, options)
36 logger.debug "Message #{message_id} successfully received" if logger && logger.debug?
37 if imap_options[:move_on_success]
38 imap.copy(message_id, imap_options[:move_on_success])
39 end
36 imap.store(message_id, "+FLAGS", [:Seen, :Deleted])
40 imap.store(message_id, "+FLAGS", [:Seen, :Deleted])
37 else
41 else
42 logger.debug "Message #{message_id} can not be processed" if logger && logger.debug?
38 imap.store(message_id, "+FLAGS", [:Seen])
43 imap.store(message_id, "+FLAGS", [:Seen])
44 if imap_options[:move_on_failure]
45 imap.copy(message_id, imap_options[:move_on_failure])
46 imap.store(message_id, "+FLAGS", [:Deleted])
47 end
39 end
48 end
40 end
49 end
41 imap.expunge
50 imap.expunge
@@ -1,4 +1,4
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
@@ -71,6 +71,11 Issue attributes control options:
71 allow_override=ATTRS allow email content to override attributes
71 allow_override=ATTRS allow email content to override attributes
72 specified by previous options
72 specified by previous options
73 ATTRS is a comma separated list of attributes
73 ATTRS is a comma separated list of attributes
74
75 Processed emails control options:
76 move_on_success=MAILBOX move emails that were successfully received
77 to MAILBOX instead of deleting them
78 move_on_failure=MAILBOX move emails that were ignored to MAILBOX
74
79
75 Examples:
80 Examples:
76 # No project specified. Emails MUST contain the 'Project' keyword:
81 # No project specified. Emails MUST contain the 'Project' keyword:
@@ -95,7 +100,9 END_DESC
95 :ssl => ENV['ssl'],
100 :ssl => ENV['ssl'],
96 :username => ENV['username'],
101 :username => ENV['username'],
97 :password => ENV['password'],
102 :password => ENV['password'],
98 :folder => ENV['folder']}
103 :folder => ENV['folder'],
104 :move_on_success => ENV['move_on_success'],
105 :move_on_failure => ENV['move_on_failure']}
99
106
100 options = { :issue => {} }
107 options = { :issue => {} }
101 %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
108 %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
General Comments 0
You need to be logged in to leave comments. Login now