Patch #3732 » patch_incoming_mail_notify_error.diff
| app/models/mailer.rb (working copy) | ||
|---|---|---|
|
subject 'Redmine test'
|
||
|
body :url => url_for(:controller => 'welcome')
|
||
|
end
|
||
|
|
||
|
def notify_incoming_error(raw_email)
|
||
|
recipients User.active.find(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact
|
||
|
subject 'Incoming mail error notification'
|
||
|
orignal_mail = TMail::Mail.parse(raw_email)
|
||
|
orignal_mail.base64_decode
|
||
|
body :original_mail =>orignal_mail;
|
||
|
end
|
||
|
# Overrides default deliver! method to prevent from sending an email
|
||
|
# with no recipient, cc or bcc
|
||
| app/views/mailer/notify_incoming_error.text.plain.rhtml (revision 0) | ||
|---|---|---|
|
This email was received by redmine and cound not be processed.
|
||
|
From :<%= @original_mail.from %>
|
||
|
Subject :<%= @original_mail.subject %>
|
||
|
------ BEGIN -------
|
||
|
<%= @original_mail.body %>
|
||
|
------ END -------
|
||
| lib/redmine/imap.rb (working copy) | ||
|---|---|---|
|
module IMAP
|
||
|
class << self
|
||
|
def check(imap_options={}, options={})
|
||
|
logger.debug "Checking messages" if logger && logger.debug?
|
||
|
host = imap_options[:host] || '127.0.0.1'
|
||
|
port = imap_options[:port] || '143'
|
||
|
ssl = !imap_options[:ssl].nil?
|
||
| ... | ... | |
|
else
|
||
|
logger.debug "Message #{message_id} can not be processed" if logger && logger.debug?
|
||
|
imap.store(message_id, "+FLAGS", [:Seen])
|
||
|
if imap_options[:notify_on_failure]
|
||
|
logger.debug "Notify for failure" if logger && logger.debug?
|
||
|
Mailer.deliver_notify_incoming_error(msg)
|
||
|
end
|
||
|
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
|
||
| lib/tasks/email.rake (working copy) | ||
|---|---|---|
|
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
|
||
|
notify_on_failure notify redmine administrators when an error occurs
|
||
|
|
||
|
Examples:
|
||
|
# No project specified. Emails MUST contain the 'Project' keyword:
|
||
| ... | ... | |
|
:password => ENV['password'],
|
||
|
:folder => ENV['folder'],
|
||
|
:move_on_success => ENV['move_on_success'],
|
||
|
:move_on_failure => ENV['move_on_failure']}
|
||
|
:move_on_failure => ENV['move_on_failure'],
|
||
|
:notify_on_failure => ENV['notify_on_failure']}
|
||
|
|
||
|
options = { :issue => {} }
|
||
|
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
|
||