子文件夹中的Rails邮件程序和邮件程序视图不起作用

 沙上的蜃楼 发布于 2023-02-13 12:10

我有一个邮件发送器,可以在日志中看到它正在发送,但是邮件正文中没有包含邮件发送器视图中的任何内容。

这是由于我已将内容放入子文件夹,并且尝试:template_pathmail函数中使用,但无济于事。

app / mailers / marketing / marketing_mailer.rb

class Marketing::MarketingMailer < ActionMailer::Base

    require 'mail'
    address = Mail::Address.new "test@example.com" # ex: "john@example.com"
    address.display_name = "Text" # ex: "John Doe"
    # Set the From or Reply-To header to the following:
    address.format # returns "John Doe "
    default from: address

    # Sends an email when someone fills out the contact form
    def contact(name, email, message)
        @name = name
        @email = email
        @message = message
        mail(:subject => "Test", :to => 'test@example.com', :reply_to => @email) # <== I've tried using :template_path => 'marketing', 'marketing/marketing_mailer', etc, but none worked.
    end
end

/app/views/marketing/marketing_mailer/contact.html.erb



  
    
  
  
    

Name: <%= @name %>

Email: <%= @email %>

Message: <%= @message %>

我注意到devise在/ views / devise / mailers / ...中有邮件视图,所以我知道这是可能的,但是我不确定如何。

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有