96 lines
2.1 KiB
Ruby
96 lines
2.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
class GeneralMails < ActionMailer::Base
|
|
add_template_helper(MailHelper)
|
|
|
|
layout 'mail'
|
|
|
|
default from: "Pollen Concepts <contact@psychologue-regny-clair.fr>"
|
|
|
|
|
|
def general(lang_slug, mail_type, email, options = {})
|
|
@options = options
|
|
|
|
@m_odr = @options[:m_odr]
|
|
@m_odr_rep = @options[:m_odr_rep]
|
|
|
|
|
|
|
|
@mail_type = mail_type
|
|
|
|
@lang = LangSite.find_by_slug(lang_slug.to_s)
|
|
|
|
@mail_content = @mail_type.mail_contents.where(:lang_site_id => @lang.id).first
|
|
|
|
subject = @mail_content.subject
|
|
|
|
@arguments = @options[:arguments]
|
|
|
|
@ccis = @options[:ccis] || []
|
|
|
|
if @options[:from]
|
|
@from = @options[:from]
|
|
elsif @m_odr and @m_odr.email_from?
|
|
@from = @m_odr.email_from
|
|
end
|
|
|
|
if @from
|
|
mail(:to => email, :subject => subject, :bcc => @ccis.join(";"), :from => @from)
|
|
else
|
|
mail(:to => email, :subject => subject, :bcc => @ccis.join(";"))
|
|
end
|
|
|
|
end
|
|
|
|
def admin(email, subject, content, options = {})
|
|
@options = options
|
|
|
|
@content = content
|
|
@arguments = @options[:arguments]
|
|
|
|
@ccis = @options[:ccis] || []
|
|
|
|
|
|
@from_admin = @options[:from_admin] if @options[:from_admin]
|
|
|
|
mail(:to => email, :subject => "Notification ADMIN : "+subject.to_s, :bcc => @ccis.join(";"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def general2(email_to, subject, body, mail_options = {})
|
|
@options = mail_options
|
|
|
|
@file_tunel = @options[:file_tunel]
|
|
@m_odr = @options[:m_odr]
|
|
|
|
@to = email_to
|
|
|
|
@body = body
|
|
|
|
|
|
@subject = subject
|
|
|
|
|
|
@ccis = @options[:ccis] || []
|
|
|
|
if @options[:from]
|
|
@from = @options[:from]
|
|
elsif @m_odr and @m_odr.email_from?
|
|
@from = @m_odr.email_from
|
|
elsif @file_tunel and @file_tunel.from_email?
|
|
@from = @file_tunel.from_email
|
|
end
|
|
|
|
if @from
|
|
mail(:to => @to, :subject => @subject, :bcc => @ccis.join(";"), :from => @from)
|
|
else
|
|
mail(:to => @to, :subject => @subject, :bcc => @ccis.join(";"))
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|