#
# == Newsletter Mailer
#
class NewsletterMailer < ApplicationMailer
  add_template_helper(HtmlHelper)
  default from: Setting.first.try(:email)
  layout 'newsletter'

  before_action :set_newsletter_settings

  # Email send after a user subscribed to the newsletter
  def welcome_user(newsletter_user)
    @newsletter_user = newsletter_user
    @newsletter_user.name = @newsletter_user.extract_name_from_email
    I18n.with_locale(@newsletter_user.lang) do
      welcome_newsletter = StringBox.find_by(key: 'welcome_newsletter')
      @title = welcome_newsletter.title
      @content = welcome_newsletter.content
    end
    @is_welcome_user = true
    @see_in_browser = true

    mail(to: @newsletter_user.email, subject: @title) do |format|
      format.html
      format.text
    end
  end

  # Email Newsletter
  def send_newsletter(newsletter_user, newsletter)
    @newsletter_user = newsletter_user
    @newsletter = newsletter
    @title = @newsletter.title

    mail(to: @newsletter_user.email, subject: @newsletter.title) do |format|
      format.html
      format.text
    end
  end

  private

  def set_newsletter_settings
    @see_in_browser = false
    @preview_newsletter = false
    @is_welcome_user = false
  end
end

#
# == Newsletter Mailer
#
class NewsletterMailer < ApplicationMailer
  add_template_helper(HtmlHelper)
  default from: Setting.first.try(:email)
  layout 'newsletter'

  before_action :set_newsletter_settings

  # Email send after a user subscribed to the newsletter
  def welcome_user(newsletter_user)
    @newsletter_user = newsletter_user
    @newsletter_user.name = @newsletter_user.extract_name_from_email
    I18n.with_locale(@newsletter_user.lang) do
      welcome_newsletter = NewsletterSetting.first
      @title = welcome_newsletter.title_subscriber
      @content = welcome_newsletter.content_subscriber
    end
    @is_welcome_user = true
    @see_in_browser = true

    mail(to: @newsletter_user.email, subject: @title) do |format|
      format.html
      format.text
    end
  end

  # Email Newsletter
  def send_newsletter(newsletter_user, newsletter)
    @newsletter_user = newsletter_user
    @newsletter = newsletter
    @title = @newsletter.title

    mail(to: @newsletter_user.email, subject: @newsletter.title) do |format|
      format.html
      format.text
    end
  end

  private

  def set_newsletter_settings
    @see_in_browser = false
    @preview_newsletter = false
    @is_welcome_user = false
  end
end

Use NewsletterSetting instead of StringBox as welcome_user mail content
Use NewsletterSetting instead of StringBox as welcome_user mail content
