Project

General

Profile

Actions

Defect #16185

open

mail_handler.rb ignored email messages return 422

Added by Francois Conil over 10 years ago. Updated about 6 years ago.

Status:
Needs feedback
Priority:
Normal
Category:
Email receiving
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

We are currently using fetchmail to process incoming mail queues similar to the situation described at #2490

When mail_handler.rb process an out of office or similar auto-submitted message, it returns false
This in turn generates an error 422, which make rdm-mailhandler.rb returns an error code 77 to fetchmail.
Fetchmail keeps reprocessing the email instead of skipping it because of this particular error message.

Is mail_handler.rb behaviour when it comes to ignored emails by design or should we return "true" when a message is successfully ignored?

Actions #1

Updated by Toshi MARUYAMA over 10 years ago

  • Description updated (diff)
Actions #2

Updated by Jean-Philippe Lang over 10 years ago

  • Status changed from New to Needs feedback

As mentionned in #4368 (see note 2), 77 exit code generally results in emails being bounced immediately with an error description but that doesn't seem to be true in your case. Maybe we could make the exit code configurable for when mail_handler.rb receives a 422 response?

Actions #3

Updated by Jean-Philippe Lang over 10 years ago

  • Assignee set to Jean-Philippe Lang
Actions #4

Updated by Francois Conil over 10 years ago

Hi Jean-Philippe,

Maybe being able to configure what to do with "auto generated" emails?

It would be very easy for me to just make it return "true", but maybe giving people the choice of skipping such emails silently would work? If I'm correct, in terms of MTA, that would be similar to a drop as opposed to a bounce.

François

Actions #5

Updated by Go MAEDA about 6 years ago

I am experiencing the same problem.

Currently, MailHandler#receive ignores auto-generated emails. Ignoring such emails is not a problem. But it returns false when it ignored auto-generated emails, and MailHandlerController#index responds "422 Unprocessable Entity" to rdm-mailhandler.rb which was invoked by an MTA such as Postfix and Sendmail. Then, rdm-mailhandler.rb returns EX_TEMPFAIL to the MTA if it gets "422 Unprocessable Entity" response.

As a result, the MTA continues to retry delivery for a few days and it will send an error notification to the original sender at last.

To avoid that, I think MailHandlerController#index should return "200 OK" instead of "422 Unprocessable Entity" when Redmine ignored an auto-generated email.


app/controllers/mail_handler_controller.rb:
MailHandlerController#index returns "422 Unprocessable Entity" when Redmine ignored an auto-generated email.

  # Submits an incoming email to MailHandler
  def index
    options = params.dup
    email = options.delete(:email)
    if MailHandler.receive(email, options)
      head :created
    else
      head :unprocessable_entity
    end
  end

extra/mail_handler/rdm-mailhandler.rb:
rdm-mailhandler.rb returns EX_TEMPFAIL to the MTA if MailHandlerController#index returned "422 Unprocessable Entity".

    begin
      response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate, :certificate_bundle => certificate_bundle)
    rescue SystemCallError, IOError => e # connection refused, etc.
      warn "An error occurred while contacting your Redmine server: #{e.message}" 
      return 75 # temporary failure
    end

Actions

Also available in: Atom PDF