https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292019-02-11T12:38:33ZRedmineRedmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900422019-02-11T12:38:33ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/14792">Defect #14792</a>: Don't add a display name and extra angle brackets in List-Id header field</i> added</li></ul> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900442019-02-11T13:38:51ZGo MAEDA
<ul></ul><p>This fix works for ordinary email addresses.</p>
<pre><code class="diff syntaxhl"><span class="gh">Index: app/models/mail_handler.rb
===================================================================
</span><span class="gd">--- app/models/mail_handler.rb (revision 17853)
</span><span class="gi">+++ app/models/mail_handler.rb (working copy)
</span><span class="p">@@ -91,7 +91,7 @@</span>
@handler_options = options
sender_email = email.from.to_a.first.to_s.strip
# Ignore emails received from the application emission address to avoid hell cycles
<span class="gd">- if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0
</span><span class="gi">+ if sender_email.casecmp(Setting.mail_from.to_s.gsub(/(?:.*<|>.*|\(.*\)|\s)/, '')) == 0
</span> if logger
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
end
</code></pre> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900622019-02-12T00:41:03ZGo MAEDA
<ul><li><strong>File</strong> <i>30785-fix.diff</i> added</li></ul><p>Here is a patch to fix this issue.</p>
<p>The patch adds a new method <code>Setting.mail_from_addess</code> to extract an email address from the value of Setting.mail_from. I think it is useful to fix <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Don't add a display name and extra angle brackets in List-Id header field (Closed)" href="https://www.redmine.org/issues/14792">#14792</a> and implement <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Authors name in from address of email notifications (Closed)" href="https://www.redmine.org/issues/5913">#5913</a>.</p> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900742019-02-12T12:06:12ZGo MAEDA
<ul><li><strong>File</strong> deleted (<del><i>30785-fix.diff</i></del>)</li></ul> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900752019-02-12T12:06:36ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/22397">30785-fix.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/22397/30785-fix.diff">30785-fix.diff</a> added</li></ul> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900762019-02-12T12:08:03ZGo MAEDA
<ul><li><strong>Target version</strong> set to <i>4.0.2</i></li></ul><p>Setting the target version to 4.0.2.</p> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900842019-02-12T23:36:33ZGo MAEDA
<ul><li><strong>Subject</strong> changed from <i>Mail handler may not ignore emails sent from emission email address</i> to <i>Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display name</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Go MAEDA</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Committed.</p> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=900852019-02-13T00:09:38ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=901662019-02-16T00:28:17ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Reopened</i></li></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>The patch adds a new method <code>Setting.mail_from_addess</code> to extract an email address from the value of Setting.mail_from. I think it is useful to fix <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Don't add a display name and extra angle brackets in List-Id header field (Closed)" href="https://www.redmine.org/issues/14792">#14792</a> and implement <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Authors name in from address of email notifications (Closed)" href="https://www.redmine.org/issues/5913">#5913</a>.</p>
</blockquote>
<p><a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Authors name in from address of email notifications (Closed)" href="https://www.redmine.org/issues/5913">#5913</a> and <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Don't add a display name and extra angle brackets in List-Id header field (Closed)" href="https://www.redmine.org/issues/14792">#14792</a> have been fixed without using newly added <code>Setting.mail_from_addess</code> method. Only MailHandler#receive uses the method now and I don't think other methods will use it in the future.</p>
<p>Therefore, I think <a class="changeset" title="Fix: Mail handler does not ignore emails sent from emission email address if Setting.mail_from in..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17862">r17862</a> should be reverted before releasing Redmine 4.0.2 and this issue should be fixed like the following:</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 9298e1b12..aed977bbd 100755
</span><span class="gd">--- a/app/models/mail_handler.rb
</span><span class="gi">+++ b/app/models/mail_handler.rb
</span><span class="p">@@ -91,7 +91,7 @@</span> class MailHandler < ActionMailer::Base
@handler_options = options
sender_email = email.from.to_a.first.to_s.strip
# Ignore emails received from the application emission address to avoid hell cycles
<span class="gd">- if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0
</span><span class="gi">+ if sender_email.casecmp(Setting.mail_from.to_s.gsub(/(?:.*<|>.*|\(.*\))/, '').strip) == 0
</span> if logger
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
end
</code></pre> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=901832019-02-17T05:02:19ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/22428">30785-fix-v2.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/22428/30785-fix-v2.patch">30785-fix-v2.patch</a> added</li></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>Therefore, I think <a class="changeset" title="Fix: Mail handler does not ignore emails sent from emission email address if Setting.mail_from in..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17862">r17862</a> should be reverted before releasing Redmine 4.0.2 and this issue should be fixed like the following:</p>
<p>[...]</p>
</blockquote>
<p>Attaching a new patch. This patch can be applied after reverting <a class="changeset" title="Fix: Mail handler does not ignore emails sent from emission email address if Setting.mail_from in..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17862">r17862</a>.</p> Redmine - Defect #30785: Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display namehttps://www.redmine.org/issues/30785?journal_id=902402019-02-18T13:52:25ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Reopened</i> to <i>Closed</i></li></ul><p>Reverted <a class="changeset" title="Fix: Mail handler does not ignore emails sent from emission email address if Setting.mail_from in..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17862">r17862</a> and applied the new patch in <a class="changeset" title="Mail handler does not ignore emails sent from emission email address if Setting.mail_from include..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17879">r17879</a>.</p>