Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I customize the Mailboxer email Subject?

I've just installed Mailboxer (gem 'mailboxer') in my Rails 3.1.1 app… I have the email notifications working.

I followed these instructions to customize the notification email that users receive when they are sent a new message via the Mailboxer engine on my app… This allows me to edit the contents of the email message they receive, but I want to change the 'Subject' in the email header from the default "Mailboxer new message:" to a customized subject.

I'm assuming there might be a line I can add to the mailboxer.rb config file?!?!?

Can anyone help on this?

like image 398
Joe Saunders Avatar asked Oct 24 '13 18:10

Joe Saunders


2 Answers

just change your en.yml file and set your own subjects:

mailboxer.message_mailer.subject_new
mailboxer.message_mailer.subject_reply

the "subject" var contains the mailboxer-message subject. Ex:

en:
  mailboxer:
    message_mailer:
      subject_new: 'Hey, you receive a new message about %{subject}'
      subject_reply: 'Hey, you receive a new reply about %{subject}'

PS: any time you can test the result at console with:

I18n.translate("mailboxer.message_mailer.subject_new", :subject => "hello")

* just change the "hello" for your actual subject

like image 157
Daniel Loureiro Avatar answered Nov 14 '22 01:11

Daniel Loureiro


So, I totally missed the obvious on this one... Just need to add a custom mailer, then you have full control.

Add the following to the mailboxer.rb config file:

Mailboxer.setup do |config|
  config.notification_mailer = CustomNotificationMailer
  config.message_mailer = CustomMessageMailer
 ...
end

As clearly noted in the wiki, here.

like image 30
Joe Saunders Avatar answered Nov 13 '22 23:11

Joe Saunders