如何自定义Mailboxer电子邮件的模板?

MKK*_*MKK 5 ruby-on-rails

它自动发送电子邮件说

You have a new message: subject

      You have received a new message:    


        Body      

      Visit http://example.com/ and go to your inbox for more info
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何自定义此模板?如果可能,我想使用i18n作为此模板表单.

谢谢!!.

Kin*_*ani 8

您需要为发送给用户的邮件生成视图, rails g mailboxer:views 这将生成两个不同的文件夹<your rails app>/app

1- notification_mailer - containing template files when a notification is sent to a user

2- message_mailer - containing template files when a message is sent to a user

您可以更改这些模板.

您可以做的另一件事是取消注释/添加这些行 /config/initializer/mailboxer.rb

config.notification_mailer = CustomNotificationMailer
config.message_mailer      = CustomMessageMailer
Run Code Online (Sandbox Code Playgroud)

并创建上面两个必须包含以下函数的邮件程序类

send_email
Run Code Online (Sandbox Code Playgroud)

此链接提供了此函数的参数及其实现.您将获得如何编写自己的send_mail函数的提示.

通知邮件程序发送电子邮件功能

Message Mailer发送电子邮件功能