mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
26 lines
695 B
Ruby
26 lines
695 B
Ruby
# Help us build an email
|
|
module EmailBuilder
|
|
|
|
def build_email(to, email_key, params={})
|
|
params[:site_name] = SiteSetting.title
|
|
params[:base_url] = Discourse.base_url
|
|
params[:user_preferences_url] = "#{Discourse.base_url}/user_preferences"
|
|
|
|
body = I18n.t("#{email_key}.text_body_template", params)
|
|
|
|
# Are we appending an unsubscribe link?
|
|
if params[:add_unsubscribe_link]
|
|
body << "\n"
|
|
body << I18n.t("unsubscribe_link", params)
|
|
end
|
|
|
|
mail_args = {
|
|
to: to,
|
|
subject: I18n.t("#{email_key}.subject_template", params),
|
|
body: body
|
|
}
|
|
mail_args[:from] = params[:from] || SiteSetting.notification_email
|
|
mail(mail_args)
|
|
end
|
|
|
|
end
|