# Customs email headers and/or subjects tags

**URL:** https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873
**Category:** Feature
**Created:** [2014 年 6 月 25 日午後 8:24 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873 "2014-06-25T20:24:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![XioNoX](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xionox/32/114446_2.png) [@XioNoX](https://meta.discourse.org/u/XioNoX)
#### Post date: [2014 年 6 月 25 日午後 8:24 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/1 "2014-06-25T20:24:01Z")

</div>

Hi!

To be able to sort automatically notification emails sent by Discourse, it would be great if they could have customs headers (or a subject tag) based on the message’s content/content:

For example, here is a list of headers Bugzilla sends with each notification email:

X-Bugzilla-Reason: CC AssignedTo  
X-Bugzilla-Type: dep\_changed  
X-Bugzilla-Watch-Reason: None  
X-Bugzilla-Classification: Other  
X-Bugzilla-ID: 1014331  
X-Bugzilla-Product: [mozilla.org](http://mozilla.org)  
X-Bugzilla-Component: Server Operations  
X-Bugzilla-Version: other  
X-Bugzilla-Keywords:  
X-Bugzilla-Severity: normal  
X-Bugzilla-Who: [foobar@email.com](mailto:foobar@email.com)  
X-Bugzilla-Status: RESOLVED  
X-Bugzilla-Resolution: FIXED  
X-Bugzilla-Priority: –  
X-Bugzilla-Assigned-To: [email@email.com](mailto:email@email.com)  
X-Bugzilla-Target-Milestone: —  
X-Bugzilla-Flags:  
X-Bugzilla-OS: Linux  
X-Bugzilla-Changed-Fields: Status Resolution  
X-Bugzilla-Changed-Field-Names: bug\_status resolution

Thanks!

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2014 年 6 月 25 日午後 8:55 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/2 "2014-06-25T20:55:25Z")

</div>

See also our discussion at:

> [@Show categories in e-mail notifications](https://meta.discourse.org/t/show-categories-in-e-mail-notifications/13814):
>
> As a standard Discourse user, I want to see standardized indication of the category assigned to a post when I receive e-mail notifications, so I can better prioritize what I reply to and when. Rationale: We’re working really hard to migrate people from a series of several mailing lists over to Discourse, and being able to specify categories in notifications somehow is pretty important to attracting those people who still want to live in their inbox. If the category were specified in the subject…

Where we’re hoping to get categories in a header. 😄

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2014 年 10 月 9 日午後 8:05 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/3 "2014-10-09T20:05:43Z")

</div>

FYI, there is now a category-specific `List-Id` header sent along with unsubscribe headers, and the ability to add your own generic headers for all notifications with the **email custom headers** site setting.

---

<div class="post-metadata">

### Author: ![llc1990](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/llc1990/32/184360_2.png) [@llc1990](https://meta.discourse.org/u/llc1990)
#### Post date: [2020 年 8 月 18 日午前 8:11 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/4 "2020-08-18T08:11:01Z")

</div>

カスタムメールヘッダーの設定方法が気になる方のために、以下に手順を示します。

1. `設定パネル >> メール` に移動するか、以下のリンクを使用してください。  
`https://forums.example.com/admin/site_settings/category/email`。ドメイン名はご自身のものに置き換えてください。

2. `email custom headers` を検索し、ご自身の設定を入力してください。これで完了です！

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [2020 年 12 月 17 日午後 11:38 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/5 "2020-12-17T23:38:45Z")

</div>

カスタムヘッダーに ` %{optional_pm}%{optional_cat}%{topic_title}` のような書式設定を指定することはできますか？

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [2022 年 1 月 5 日午後 7:55 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/6 "2022-01-05T19:55:17Z")

</div>

念のため、これをテストしたところ、答えは「いいえ、拡張はありません」でした。たとえば、次のような結果が得られます。

`X-Tags: %{optional_tags}`

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2022 年 1 月 8 日午前 1:03 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/7 "2022-01-08T01:03:28Z")

</div>

`%{optional_tags}` のようなものが `email custom headers` サイト設定に追加されたヘッダーに代入されるようなコードはどこにも見当たりません。カスタムヘッダーの値の設定に使用されているこのメソッドを見つけました。

> <https://github.com/discourse/discourse/blob/main/lib/email/sender.rb#L433>

これは以下から呼び出されています。

> <https://github.com/discourse/discourse/blob/main/lib/email/sender.rb#L229>

設定がどのように使用されることを意図しているのか、カスタムヘッダーに代入できる値は何かについて、Discourse チームから詳細情報を入手しようと思います。

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [2022 年 1 月 8 日午後 4:31 UTC](https://meta.discourse.org/t/customs-email-headers-and-or-subjects-tags/16873/8 "2022-01-08T16:31:12Z")

</div>

@simon 比較してください。

> <https://github.com/discourse/discourse/blob/c0d72ec3d616fab2448009dadfd69228c46611cf/lib/email/message_builder.rb#L188>

と

> <https://github.com/discourse/discourse/blob/c0d72ec3d616fab2448009dadfd69228c46611cf/lib/email/message_builder.rb#L53>

テンプレートとemail\_subject設定には複雑さがありますが、私はそれを完全に理解していません。テンプレートがある場合、後者は使用されないようですが、テンプレートがない場合はどうなるのかわかりません！しかし、それはさておき、基本的なことは、カスタムヘッダーを構築した関数が同じテンプレートを使用していれば、これは機能し、カスタムヘッダーには有用な動的な情報を含めることができるということです。
