プロジェクト

全般

プロフィール

Vote #74271

完了

Cannot change "From" header in email notifications

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
88
issue_org_id:
14699
author_id:
35462
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

In Redmine 1.x (Rails 2.3), using from method in custom mailer changed the From header from Setting.mail_from.

According to Rails 3 Action Mailer documentation, mail method can receive :from header. Redmine 2.x's Mailer#mail does header.merge!{'From'=>Setting.mail_from,...}. This results in the from header being overridden and removes default functionality.

I have made a change to Mailer#mail to do header.reverse_merge! instead of header.merge!, but I am unsure if this is the best path. However, this did set up the email headers correctly.


journals

Here is a patch where we use the @headers.reverse_merge!@ method instead of @headers.merge!@

As we can pass headers as a parameter, I think we should use a reverse_merge in order to not override our hash with default values:

<pre>
def mail(headers={}, &block)
headers.reverse_merge! 'X-Mailer' => 'Redmine',
'X-Redmine-Host' => Setting.host_name,
'X-Redmine-Site' => Setting.app_title,
'X-Auto-Response-Suppress' => 'OOF',
'Auto-Submitted' => 'auto-generated',
'From' => Setting.mail_from,
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
</pre>

This could be very useful in some of my plugins. Thanks
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Fix committed in r13784, thanks.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン2.6.1_88 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0