Class: MailEngine::Base
- Inherits:
-
Object
- Object
- MailEngine::Base
- Defined in:
- lib/mail_engine/base.rb
Constant Summary
- @@configurations =
HashWithIndifferentAccess.new
Class Method Summary (collapse)
-
+ (Object) current_config
return current runtime environment config hash.
-
+ (Object) send_marketing_mail(template, *args)
send mail template with given data.
Class Method Details
+ (Object) current_config
return current runtime environment config hash.
example
log_mail: true sendgrid_user: "xxx@theplant.jp" sendgrid_key: "xxx" sendgrid_category: "development" user_class_name: "User" mount_at: "/admin"
17 18 19 |
# File 'lib/mail_engine/base.rb', line 17 def current_config MailEngine::Base.configurations[Rails.env] end |
+ (Object) send_marketing_mail(template, *args)
send mail template with given data.
example
MailEngine::Base.send_marketing_mail("newsletter", :to => 'm@theplant.jp', :values => {:users => MailEngine::USER_MODEL.last})
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mail_engine/base.rb', line 26 def send_marketing_mail(template, *args) = args. [:locale] ||= I18n.locale # ensure the :to parameter. raise "Should specify :to option" if [:to].blank? # find the template from database. template_path = File.join("mail_engine", "mail_dispatcher", template) unless mail_template = MailEngine::MailTemplate.where(:path => template_path, :locale => [:locale], :for_marketing => true, :partial => false).first raise "Can't find the template: #{template_path}" end [:subject] ||= mail_template.subject I18n.with_locale(mail_template.locale) do MailEngine::MailDispatcher.send(template, ).deliver end end |