class SupportMailer < ActionMailer::Base
default :from => "[email protected]"
def welcome_email(ticket)
case ticket.game
when "gameone"
@ticket = ticket
headers["Reply-to"] = "email1+#{ticket.token}@gmail.com"
headers["Return-Path"] = "email1+#{ticket.token}@gmail.com"
mail(:from => "[email protected]", :to => ticket.email, :subject => "Welcome to 1 Support Ticket")
when "gametwo"
@ticket = ticket
headers["Reply-to"] = "email2+#{ticket.token}@gmail.com"
headers["Return-Path"] = "email2+#{ticket.token}@gmail.com"
mail(:from => "[email protected]", :to => ticket.email, :subject => "Welcome to 2 Support Ticket")
when "gamethree"
@ticket = ticket
headers["Reply-to"] = "email3+#{ticket.token}@gmail.com"
header["Return-Path"] = "email3+#{ticket.token}@gmail.com"
mail(:from => "[email protected]", :to => ticket.email, :subject => "Welcome to 3 Support Ticket")
end
end
end
我已经设置了默认的:from,所以我不明白为什么我继续收到此消息,我也试图通过 header 将其设置为无效。
这是我的设置
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "[email protected]",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}
我只是这样称呼它,
SupportMailer.support_response(@message).deliver
我该如何解决?
最佳答案
我注意到您没有case语句的默认大小写。如果您从未最终在Mailer类的方法中调用“mail”方法,则将得到该错误。尝试将您的案例声明移到调用SupportMailer的位置,也许每种案例都有相应的方法。这样,除非您已经确定了正确的彩票游戏,否则您永远不会致电SupportMailer。
关于ruby-on-rails-3 - 不断收到发送消息所需的发件人(返回路径,发件人或发件人),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9690356/