generated from BCDevOps/opendev-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapplication_mailer.rb
More file actions
36 lines (32 loc) · 888 Bytes
/
application_mailer.rb
File metadata and controls
36 lines (32 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class ApplicationMailer < ActionMailer::Base
default from: ENV["FROM_EMAIL"]
layout "mailer"
protected
# template_key should match i18n as well as the name of the file in the views
def send_mail(
email:,
template_key:,
subject_i18n_params: {},
include_subject_start: true
)
@root_url = FrontendUrlHelper.root_url
subject_key =
I18n.t(
"application_mailer.subjects.#{template_key}",
**subject_i18n_params
)
subject =
(
if include_subject_start
"#{I18n.t("application_mailer.subject_start")} - #{subject_key}"
else
subject_key
end
)
mail(
to: email,
subject:,
template_name: template_key # this isn't fully necessary since rails introspects it anyway, but here for clarity (template_path is also auto introspected by rails)
)
end
end