Vote #74975
未完了mail_handler.rb ignored email messages return 422
0%
説明
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?
journals
--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
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.
<pre><code class="ruby">
# 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
</code></pre>
extra/mail_handler/rdm-mailhandler.rb:
@rdm-mailhandler.rb@ returns EX_TEMPFAIL to the MTA if MailHandlerController#index returned "422 Unprocessable Entity".
<pre><code class="ruby">
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
</code></pre>
--------------------------------------------------------------------------------