我有一个邮件发送器,可以在日志中看到它正在发送,但是邮件正文中没有包含邮件发送器视图中的任何内容。
这是由于我已将内容放入子文件夹,并且尝试:template_path
在mail
函数中使用,但无济于事。
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 / ...中有邮件视图,所以我知道这是可能的,但是我不确定如何。