简体   繁体   English

如何在Rails上禁用特定的邮件程序?

[英]How to disable a specific mailer on Rails?

So I'm building an e-commerce platform using Shoppe 1.0.7. 因此,我正在使用Shoppe 1.0.7构建一个电子商务平台。

Basically, I'd like my customers to get an e-mail with their order confirmation, their item listing, etc, so I built a mailer that does just that. 基本上,我希望我的客户收到一封包含订单确认,商品清单等信息的电子邮件,因此我建立了一个邮件收发器来执行此操作。

When I got it working, I found out Shoppe actually sends out its own confirmation e-mails, but these are way more generic and uninformative than mine are (also they're in English and I need mine in another language). 当我开始使用它时,我发现Shoppe实际上会发送自己的确认电子邮件,但是这些电子邮件比我的电子邮件更加通用和毫无信息(它们也是英语的,我需要我用另一种语言)。 So as it is, my customers are actually getting two e-mails when they make an order, which is obviously undesirable. 因此,我的客户在下订单时实际上收到了两封电子邮件,这显然是不可取的。

How do I disable Shoppe's mailer without disabling Shoppe as a whole (which I obviously need)? 如何禁用Shoppe的邮件程序而不禁用整个Shoppe(我显然需要)?

I'm not familiar with Shoppe but I can't see any configuration options around the mail on first glance. 我对Shoppe不熟悉,但乍一看看不到邮件周围的任何配置选项。 There are four actions in the OrderMailer and they only seem to be used here and here . OrderMailer中有四个动作 ,它们似乎仅在此处此处使用 An option would be to open up the mailer class and redefine the methods. 一种选择是打开邮件程序类并重新定义方法。

module Shoppe
  class OrderMailer
    def received(order)
      true
    end
  end
end

It's not the best solution to have to monkey patch like this, a better option would be to use an action mailer interceptor . 像这样的猴子补丁并不是最好的解决方案,更好的选择是使用动作邮件拦截器 Alternatively you could see if any issues for this have been raised on their repo and if not submit one, or a PR that would allow mail to be configured. 或者,您可以查看是否在其回购中提出了任何与此相关的问题,如果未提交,或者提供了可以配置邮件的PR。 Might be a nice feature to push upstream. 可能是向上游推送的好功能。

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

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