我正在使用 rails3.0.6 和 ruby 1.8.7,我可以轻松地从我的应用程序开发模式发送电子邮件。但是昨晚我尝试向我的客户电子邮件发送邮件时看到一个新错误,该邮件与我的发票模型相关联。错误是:
Net::SMTPSyntaxError in InvoicesController#email_invoice
501 < @invoice.account.accountable.email >: missing or malformed local part
我的 email.rb 文件代码是:
def send_invoice(invoice)
email = '@invoice.account.accountable.email'
mail(:to => email, :from => "support@thenextwave.in", :subject=>"Invoice, check it.")
end
在我的invoice controller
我做了:
def email_invoice
@company = Company.find(User.find(session[:current_user_id]))
@invoice = Invoice.find(params[:id])
@invoice_line_items = @invoice.invoice_line_items
@receipt_vouchers = @invoice.receipt_vouchers
#email = @invoice.account.accountable.email
Email.send_invoice(@invoice).deliver
redirect_to invoice_path(@invoice)
flash[:success] = 'Email has been sent successfully.'
end
我仔细检查了这个错误,发现它是由于电子邮件地址错误或 SMTP 设置错误引起的,但我的 SMTP 设置没问题,因为我可以从我的应用程序发送电子邮件,但下面一行有问题:
@invoice.account.accountable.email
任何帮助都会非常感谢..