From 0af1242aa8fb96cb26961715cba6161c62f058e4 Mon Sep 17 00:00:00 2001 From: Peter N Lewis Date: Fri, 6 Jun 2014 21:09:00 +0800 Subject: [PATCH] Use an appropriate name in the Reply-To header Use "Site Name <>" for the Reply-To header when the reply is to the site or a public topic. Use "username <>" for the Reply-To header only when the reply is to a private message topic. --- app/mailers/user_notifications.rb | 1 + lib/email/message_builder.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 5981e879699..f86bc2cdc41 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -215,6 +215,7 @@ class UserNotifications < ActionMailer::Base username: from_alias, add_unsubscribe_link: true, allow_reply_by_email: allow_reply_by_email, + private_reply: post.topic.private_message?, include_respond_instructions: !user.suspended?, template: template, html_override: html, diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rb index 130d3a7cf96..bba5be187d7 100644 --- a/lib/email/message_builder.rb +++ b/lib/email/message_builder.rb @@ -136,6 +136,13 @@ module Email @opts[:allow_reply_by_email] end + def private_reply? + SiteSetting.reply_by_email_enabled? && + reply_by_email_address.present? && + @opts[:allow_reply_by_email] && + @opts[:private_reply] + end + def from_value return @from_value if @from_value @from_value = @opts[:from] || SiteSetting.notification_email @@ -149,7 +156,11 @@ module Email @reply_by_email_address = SiteSetting.reply_by_email_address.dup @reply_by_email_address.gsub!("%{reply_key}", reply_key) - @reply_by_email_address = alias_email(@reply_by_email_address) + @reply_by_email_address = if private_reply? + alias_email(@reply_by_email_address) + else + site_alias_email(@reply_by_email_address) + end @reply_by_email_address end @@ -159,6 +170,10 @@ module Email "#{@opts[:from_alias]} <#{source}>" end + def site_alias_email(source) + return "#{SiteSetting.title} <#{source}>" + end + end end