5

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?

Community
  • 1
  • 1
Joe Saunders
  • 798
  • 1
  • 9
  • 27

2 Answers2

9

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

Daniel Loureiro
  • 4,595
  • 34
  • 48
5

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.

Joe Saunders
  • 798
  • 1
  • 9
  • 27
  • 2
    I saw this in the wiki, but I don't like having to create an entirely new class just to change the subject. – Jeff Oct 29 '13 at 18:23
  • Yeah, I thought there would be an easier variable setting or something... It's not that difficult if you copy the mailer views, do this first: `rails g mailboxes:views`, then you can copy the views that generates into your mailer – Joe Saunders Oct 29 '13 at 18:27