[#792] Send email from mail_handler for emails missing a project
This commit is contained in:
parent
4ff670f5fa
commit
1dd07471ca
|
@ -106,6 +106,7 @@ class MailHandler < ActionMailer::Base
|
|||
false
|
||||
rescue MissingInformation => e
|
||||
logger.error "MailHandler: missing information from #{user}: #{e.message}" if logger
|
||||
Mailer.deliver_mail_handler_missing_information(user, email.subject.to_s, e.message) if Setting.mail_handler_confirmation_on_failure
|
||||
false
|
||||
rescue UnauthorizedAction => e
|
||||
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
||||
|
|
|
@ -316,6 +316,13 @@ class Mailer < ActionMailer::Base
|
|||
render_multipart('mail_handler_unauthorized_action', body)
|
||||
end
|
||||
|
||||
def mail_handler_missing_information(user, email_subject, error_message)
|
||||
recipients user.mail
|
||||
subject l(:label_mail_handler_failure, :subject => email_subject)
|
||||
body({:errors => error_message.to_s})
|
||||
render_multipart('mail_handler_missing_information', body)
|
||||
end
|
||||
|
||||
def test(user)
|
||||
redmine_headers 'Type' => "Test"
|
||||
set_language_if_valid(user.language)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<p><%= l(:label_mail_handler_errors_with_submission) %></p>
|
||||
|
||||
<p><%= h(@errors) %></p>
|
|
@ -0,0 +1,3 @@
|
|||
<%= l(:label_mail_handler_errors_with_submission) %>
|
||||
|
||||
<%= h(@errors) %>
|
|
@ -821,7 +821,8 @@ en:
|
|||
label_toc: "Contents"
|
||||
label_mail_handler_confirmation: "Confirmation of email submission: %{subject}"
|
||||
label_mail_handler_failure: "Failed email submission: %{subject}"
|
||||
|
||||
label_mail_handler_errors_with_submission: "There were errors with your email submission:"
|
||||
|
||||
button_login: Login
|
||||
button_submit: Submit
|
||||
button_save: Save
|
||||
|
|
|
@ -476,12 +476,29 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
assert mail.bcc.include?('jsmith@somenet.foo')
|
||||
assert mail.to.include?('jsmith@somenet.foo')
|
||||
assert mail.subject.include?('Failed email submission: Re: Add ingredients categories')
|
||||
assert mail.body.include?('You are not authorized to perform this action')
|
||||
end
|
||||
end
|
||||
|
||||
context "with an email that is missing required information" do
|
||||
should "deliver an email error confirmation to the sender for a missing project" do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
issue = submit_email('ticket_with_attachment.eml') # No project set
|
||||
assert_equal false, issue
|
||||
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
assert mail.to.include?('jsmith@somenet.foo')
|
||||
assert mail.subject.include?('Failed email submission: Ticket created by email with attachment')
|
||||
assert mail.body.include?('There were errors with your email submission')
|
||||
assert mail.body.include?('Unable to determine target project')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context "#receive_issue" do
|
||||
should "deliver an email confirmation when configured" do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
|
Loading…
Reference in New Issue