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.
This commit is contained in:
Peter N Lewis 2014-06-06 21:09:00 +08:00
parent 72130357ed
commit 0af1242aa8
2 changed files with 17 additions and 1 deletions

View File

@ -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,

View File

@ -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