Class: PostNotifyMailer

Inherits:
DmCore::SiteMailer
  • Object
show all
Defined in:
app/mailers/post_notify_mailer.rb

Instance Method Summary collapse

Instance Method Details

#post_notify(user, post, account) ⇒ Object

send notification email, using the users preferred locale if possible




12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/mailers/post_notify_mailer.rb', line 12

def post_notify(user, post, )
  Account.current               =   # needed so this can run in a background job
  # Account.current.set_default_values
  locale                        = .verify_locale(user.locale)
  I18n.with_locale(locale) do
    @subject                    = "Blog: #{post.cms_blog.title} :: #{post.title}"
    @recipients                 = user.email
    @blog_title                 = post.cms_blog.title
    @post_title                 = post.title
    @post_link                  = dm_cms.post_show_url(post.cms_blog.slug, post.slug, locale: locale, host: .url_host, protocol: .url_protocol)
    @post                       = post
    @header_image               = post.cms_blog.image_email_header || post.cms_blog.header_image

    headers = { "Return-Path" => .preferred_blog_from_email || .preferred_smtp_from_email }
    mail( from: .preferred_blog_from_email || .preferred_smtp_from_email,
          reply_to: .preferred_blog_from_email || .preferred_smtp_from_email,
          to: @recipients, subject: @subject,
          theme: .) do |format|
      format.text { render "layouts/email_templates/dm_cms_post_notify.text.erb" }
      format.html { render "layouts/email_templates/dm_cms_post_notify.html.erb" }
    end
  end
end