XioNoX
(XioNoX)
2014 年 6 月 25 日午後 8:24
1
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
X-Bugzilla-Component: Server Operations
X-Bugzilla-Version: other
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: foobar@email.com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: –
X-Bugzilla-Assigned-To: 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!
「いいね!」 3
downey
(Michael Downey)
2014 年 6 月 25 日午後 8:55
2
See also our discussion at:
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.
downey
(Michael Downey)
2014 年 10 月 9 日午後 8:05
3
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.
「いいね!」 2
For those who are wondering how to set the custom email header, here it is.
Go to your Settings Panel >> Email or use below link
https://forums.example.com/admin/site_settings/category/email, you should replace the domain name with your own.
Search for email custom headers, and set your own. That’s it!
mattdm
(Matthew Miller)
2020 年 12 月 17 日午後 11:38
5
Can formatting things like %{optional_pm}%{optional_cat}%{topic_title} go in the custom headers?
「いいね!」 1
mattdm
(Matthew Miller)
2022 年 1 月 5 日午後 7:55
6
念のため、これをテストしたところ、答えは「いいえ、拡張はありません」でした。たとえば、次のような結果が得られます。
X-Tags: %{optional_tags}
「いいね!」 1
simon
2022 年 1 月 8 日午前 1:03
7
%{optional_tags} のようなものが email custom headers サイト設定に追加されたヘッダーに代入されるようなコードはどこにも見当たりません。カスタムヘッダーの値の設定に使用されているこのメソッドを見つけました。
!@stripped_secure_upload_shas.include?(optimized_1X&.sha1)
)
return
end
if (optimized_1X&.filesize || upload.filesize) >
SiteSetting.secure_uploads_max_email_embed_image_size_kb.kilobytes
return
end
true
end
#
# Two behaviors in the mail gem collide:
#
# 1. Attachments are added as extra parts at the top level,
# 2. When there are both text and html parts, the content type is set
# to 'multipart/alternative'.
#
# Since attachments aren't alternative renderings, for emails that contain
# attachments and both html and text parts, some coercing is necessary.
#
これは以下から呼び出されています。
# to the array of values for the header.
@message.header[key] = nil
@message.header[key] = our_value
end
value = header_value(key)
# Remove Auto-Submitted header for group private message emails, it does
# not make sense there and may hurt deliverability.
#
# From https://www.iana.org/assignments/auto-submitted-keywords/auto-submitted-keywords.xhtml:
#
# > Indicates that a message was generated by an automatic process, and is not a direct response to another message.
@message.header[key] = nil if key.downcase == "auto-submitted" && smtp_group_id
# Replace reply_key in custom headers or remove
if value&.include?("%{reply_key}")
# Delete old header first or else the same header will be added twice
@message.header[key] = nil
@message.header[key] = value.gsub!("%{reply_key}", reply_key) if reply_key.present?
end
設定がどのように使用されることを意図しているのか、カスタムヘッダーに代入できる値は何かについて、Discourse チームから詳細情報を入手しようと思います。
mattdm
(Matthew Miller)
2022 年 1 月 8 日午後 4:31
8
@simon 比較してください。
# No point in adding a reply-to header if it is going to be identical
# to the from address/alias. If the from option is not present, then
# the default reply-to address is used.
result['Reply-To'] = from_value if from_value != alias_email(@opts[:from])
end
end
result.merge(MessageBuilder.custom_headers(SiteSetting.email_custom_headers))
end
def self.custom_headers(string)
result = {}
string.split('|').each { |item|
header = item.split(':', 2)
if header.length == 2
name = header[0].strip
value = header[1].strip
result[name] = value if name.length > 0 && value.length > 0
end
} unless string.nil?
result
と
elsif SiteSetting.unsubscribe_via_email_footer
"unsubscribe_link_and_mail"
else
"unsubscribe_link"
end
@template_args[:unsubscribe_instructions] = I18n.t(unsubscribe_string, @template_args)
end
end
end
def subject
if @opts[:template] &&
TranslationOverride.exists?(locale: I18n.locale, translation_key: "#{@opts[:template]}.subject_template")
augmented_template_args = @template_args.merge({
site_name: @template_args[:email_prefix],
optional_re: @opts[:add_re_to_subject] ? I18n.t('subject_re') : '',
optional_pm: @opts[:private_reply] ? @template_args[:subject_pm] : '',
optional_cat: @template_args[:show_category_in_subject] ? "[#{@template_args[:show_category_in_subject]}] " : '',
optional_tags: @template_args[:show_tags_in_subject] ? "#{@template_args[:show_tags_in_subject]} " : '',
topic_title: @template_args[:topic_title] ? @template_args[:topic_title] : '',
})
テンプレートとemail_subject設定には複雑さがありますが、私はそれを完全に理解していません。テンプレートがある場合、後者は使用されないようですが、テンプレートがない場合はどうなるのかわかりません!しかし、それはさておき、基本的なことは、カスタムヘッダーを構築した関数が同じテンプレートを使用していれば、これは機能し、カスタムヘッダーには有用な動的な情報を含めることができるということです。
「いいね!」 2