简体   繁体   English

如何在例外通知中发送自定义电子邮件?

[英]How to send custom email in exception notification?

I have used exception notification gem to send exceptions to email, the email contains lots of data I want to minimize the data for eg I don't want to send Environment details 我已经使用异常通知 gem将异常发送给电子邮件,该电子邮件包含很多数据,例如,我不想发送环境详细信息,我希望将这些数据最小化

    ------------------------------
     Environment:
    -------------------------------

Is there any way skip environment details on the exception mail? 有什么办法可以跳过异常邮件上的环境详细信息?

You can customize the sections. 您可以自定义部分。 Read the documentation on github . 阅读github上的文档。 There they said we can customize. 他们说在那里可以定制。

By default, the notification email includes four parts: request, session, environment, and backtrace (in that order). 默认情况下,通知电子邮件包括四个部分:请求,会话,环境和回溯(按此顺序)。 You can customize how each of those sections are rendered by placing a partial named for that part in your app/views/exception_notifier directory (eg, _session.rhtml). 您可以通过在app / views / exception_notifier目录(例如_session.rhtml)中放置一个为该部分命名的部分来自定义这些部分的呈现方式。

You can reorder the sections, or exclude sections completely, by using sections option. 您可以使用“部分”选项重新排列部分,或完全排除部分。 You can even add new sections that describe application-specific data--just add the section's name to the list (wherever you'd like), and define the corresponding partial. 您甚至可以添加描述特定于应用程序的数据的新部分-只需将该部分的名称添加到列表中(无论您要在何处),然后定义相应的部分即可。 Like the following example with two new added sections: 类似于以下示例,其中添加了两个新部分:

  Rails.application.config.middleware.use ExceptionNotification::Rack,
   :email => {
   :email_prefix => "[PREFIX] ",
   :sender_address => %{"notifier" <notifier@example.com>},
   :exception_recipients => %w{exceptions@example.com},
   :sections => %w{my_section1 my_section2}
}

Place your custom sections under ./app/views/exception_notifier/ with the suffix .text.erb, eg ./app/views/exception_notifier/_my_section1.text.erb . 将自定义部分放在后缀为.text.erb的./app/views/exception_notifier/下,例如./app/views/exception_notifier/_my_section1.text.erb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM