错误似乎非常不具描述性:
failed with ArgumentError: A sender (Return-Path, Sender or From) required to send a message
我认为这不是真正的问题,因为我已经尝试指定“from”,即使我设置了默认值。此外,localhost和Heroku的代码相同......
def invite_dealer(auction, name, email, dealer)
return false if dealer.bids.where("auction_id = ?", auction.id).present?
@name = name #used on template
@email = email
@auction = auction #this too
mail(:to => @email, :subject => "New Auction - #{auction.car.name}", :from => "realaddressishereonmymachine@ourdomain.com")
end
答案 0 :(得分:2)
如果未从failed with ArgumentError: A sender (Return-Path, Sender or From) required to send a message
方法调用mail
方法,则会出现错误invite_dealer
。
因此,在调用return
方法之前将条件invite_dealer
放入mail
方法是个坏主意。
答案 1 :(得分:0)
将此行添加到development.rb似乎修复了它 - 奇怪所有其他邮件方法都在工作:
Rails.application.routes.default_url_options[:host]= 'localhost:3000'