2008-12-31 17:56:30 +03:00
|
|
|
# Redmine - project management software
|
2008-06-22 14:45:03 +04:00
|
|
|
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2008-06-22 16:27:00 +04:00
|
|
|
namespace :redmine do
|
|
|
|
namespace :email do
|
|
|
|
|
|
|
|
desc <<-END_DESC
|
2008-06-22 14:45:03 +04:00
|
|
|
Read an email from standard input.
|
|
|
|
|
2008-07-06 20:26:25 +04:00
|
|
|
Issue attributes control options:
|
|
|
|
project=PROJECT identifier of the target project
|
2008-11-30 17:57:46 +03:00
|
|
|
status=STATUS name of the target status
|
2008-07-06 20:26:25 +04:00
|
|
|
tracker=TRACKER name of the target tracker
|
|
|
|
category=CATEGORY name of the target category
|
|
|
|
priority=PRIORITY name of the target priority
|
|
|
|
allow_override=ATTRS allow email content to override attributes
|
|
|
|
specified by previous options
|
|
|
|
ATTRS is a comma separated list of attributes
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
# No project specified. Emails MUST contain the 'Project' keyword:
|
|
|
|
rake redmine:email:read RAILS_ENV="production" < raw_email
|
|
|
|
|
|
|
|
# Fixed project and default tracker specified, but emails can override
|
|
|
|
# both tracker and priority attributes:
|
|
|
|
rake redmine:email:read RAILS_ENV="production" \\
|
|
|
|
project=foo \\
|
|
|
|
tracker=bug \\
|
|
|
|
allow_override=tracker,priority < raw_email
|
2008-06-22 14:45:03 +04:00
|
|
|
END_DESC
|
|
|
|
|
2008-07-06 20:26:25 +04:00
|
|
|
task :read => :environment do
|
|
|
|
options = { :issue => {} }
|
2008-11-30 17:57:46 +03:00
|
|
|
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
|
2008-07-06 20:26:25 +04:00
|
|
|
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
|
2008-06-22 14:45:03 +04:00
|
|
|
|
|
|
|
MailHandler.receive(STDIN.read, options)
|
|
|
|
end
|
2008-06-22 16:27:00 +04:00
|
|
|
|
|
|
|
desc <<-END_DESC
|
|
|
|
Read emails from an IMAP server.
|
|
|
|
|
|
|
|
Available IMAP options:
|
2008-07-06 20:26:25 +04:00
|
|
|
host=HOST IMAP server host (default: 127.0.0.1)
|
|
|
|
port=PORT IMAP server port (default: 143)
|
|
|
|
ssl=SSL Use SSL? (default: false)
|
|
|
|
username=USERNAME IMAP account
|
|
|
|
password=PASSWORD IMAP password
|
|
|
|
folder=FOLDER IMAP folder to read (default: INBOX)
|
|
|
|
|
|
|
|
Issue attributes control options:
|
|
|
|
project=PROJECT identifier of the target project
|
2008-11-30 17:57:46 +03:00
|
|
|
status=STATUS name of the target status
|
2008-07-06 20:26:25 +04:00
|
|
|
tracker=TRACKER name of the target tracker
|
|
|
|
category=CATEGORY name of the target category
|
|
|
|
priority=PRIORITY name of the target priority
|
|
|
|
allow_override=ATTRS allow email content to override attributes
|
|
|
|
specified by previous options
|
|
|
|
ATTRS is a comma separated list of attributes
|
2008-12-31 17:56:30 +03:00
|
|
|
|
|
|
|
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
|
2008-07-06 20:26:25 +04:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
# No project specified. Emails MUST contain the 'Project' keyword:
|
|
|
|
|
|
|
|
rake redmine:email:receive_iamp RAILS_ENV="production" \\
|
2008-08-25 20:35:20 +04:00
|
|
|
host=imap.foo.bar username=redmine@example.net password=xxx
|
2008-07-06 20:26:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
# Fixed project and default tracker specified, but emails can override
|
|
|
|
# both tracker and priority attributes:
|
2008-06-22 16:27:00 +04:00
|
|
|
|
2008-07-06 20:26:25 +04:00
|
|
|
rake redmine:email:receive_iamp RAILS_ENV="production" \\
|
2008-08-25 20:35:20 +04:00
|
|
|
host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\
|
2008-07-06 20:26:25 +04:00
|
|
|
project=foo \\
|
|
|
|
tracker=bug \\
|
|
|
|
allow_override=tracker,priority
|
2008-06-22 16:27:00 +04:00
|
|
|
END_DESC
|
|
|
|
|
|
|
|
task :receive_imap => :environment do
|
|
|
|
imap_options = {:host => ENV['host'],
|
|
|
|
:port => ENV['port'],
|
|
|
|
:ssl => ENV['ssl'],
|
|
|
|
:username => ENV['username'],
|
|
|
|
:password => ENV['password'],
|
2008-12-31 17:56:30 +03:00
|
|
|
:folder => ENV['folder'],
|
|
|
|
:move_on_success => ENV['move_on_success'],
|
|
|
|
:move_on_failure => ENV['move_on_failure']}
|
2008-06-22 16:27:00 +04:00
|
|
|
|
2008-07-06 20:26:25 +04:00
|
|
|
options = { :issue => {} }
|
2008-11-30 17:57:46 +03:00
|
|
|
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
|
2008-07-06 20:26:25 +04:00
|
|
|
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
|
2008-06-22 16:27:00 +04:00
|
|
|
|
|
|
|
Redmine::IMAP.check(imap_options, options)
|
|
|
|
end
|
2008-06-22 14:45:03 +04:00
|
|
|
end
|
|
|
|
end
|