* refactor: set the email_from to use in teh defaults * chore: remove some new lines * feat: add a mail link helper that can be used in the views * feat: returns the default if it doesn't understand the parameter * feat: Quick replacement of links * feat: allow subject to be passed through * chore: update all hrefs * chore: remove rel attribute * chore: mail link * update spec * chore: space * chore: update some whitespaces and emails * style * chore: PR mail_link to email_link and the comment * feat: PR suggestions for encoding * feat: use mail_to
25 lines
811 B
Ruby
25 lines
811 B
Ruby
class ApplicationMailer < ActionMailer::Base
|
|
layout "mailer"
|
|
# the order of importing the helpers here is important
|
|
# we want the application helpers to override the Rails route helpers should there be a name conflict
|
|
# an example is the user_url
|
|
helper Rails.application.routes.url_helpers
|
|
helper ApplicationHelper
|
|
|
|
default(
|
|
from: -> { email_from("Community") },
|
|
template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" },
|
|
)
|
|
|
|
def email_from(topic)
|
|
"#{ApplicationConfig['COMMUNITY_NAME']} #{topic} <#{SiteConfig.email_addresses[:default]}>"
|
|
end
|
|
|
|
def generate_unsubscribe_token(id, email_type)
|
|
Rails.application.message_verifier(:unsubscribe).generate(
|
|
user_id: id,
|
|
email_type: email_type.to_sym,
|
|
expires_at: 31.days.from_now,
|
|
)
|
|
end
|
|
end
|