# Replacing email/notification.html via custom Plugin - tips?

**URL:** <https://meta.discourse.org/t/replacing-email-notification-html-via-custom-plugin-tips/87529>\
**Category:** Development\
**Created:** [May 15, 2018, 12:02pm UTC](https://meta.discourse.org/t/replacing-email-notification-html-via-custom-plugin-tips/87529 "2018-05-15T12:02:47Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Maisy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maisy/32/119902_2.png) [@Maisy](https://meta.discourse.org/u/Maisy)\
**Post date:** [May 16, 2018, 3:18pm UTC](https://meta.discourse.org/t/replacing-email-notification-html-via-custom-plugin-tips/87529/3 "2018-05-16T15:18:18Z")

</div>

Well, since yesterdaty, I’ve managed to make _something_ happen. I don’t think it’s particularly clean, but here it is.

In my **plugin.rb** file:

```rb
# This attempts to override the Notification Emails by sliding in 
# our custom template directory first.
require_dependency 'user_notifications'
module ::UserNotificationsOverride
    def send_notification_email(opts)
        Rails.configuration.paths["app/views"].unshift(File.expand_path("../templates", __FILE__ ))
        super(opts)
    end
end

class ::UserNotifications
    prepend ::UserNotificationsOverride
end

```

…and then adjacent to the plugin file is a **template/** directory that contains customised .erb files using the same structure as below **/app/views**. So my plugin now looks like:

```plaintext
/my-email-plugin
├── plugin.rb
└── templates
    └── email
        ├── _post.html.erb
        ├── invite.html.erb
        ├── notification.html.erb
        └── template.html.erb

```

What I wanted to do was shift my custom templates folder ahead of the default, in an attempt to replicate what the `::ActionMailer::Base.prepend_view_path` line was doing, but without breaking anything else or by carbon-copying the entire `send_notification_email` method for the sake of changing one line.

If you can think of any ways to improve this, then please do share. 🙂

---

_[View the full topic](https://meta.discourse.org/t/replacing-email-notification-html-via-custom-plugin-tips/87529)._
