在任何邮件程序中定义一个名为receive的方法后,Action Mailer会将原始传入的电子邮件解析为电子邮件对象,对其进行解码,实例化新的邮件程序,并将电子邮件对象传递给邮件程序接收实例方法。这是一个例子:
class UserMailer < ActionMailer::Base
def receive(email)
page = Page.find_by_address(email.to.first)
page.emails.create(
subject: email.subject,
body: email.body
)
if email.has_attachments?
email.attachments.each do |attachment|
page.attachments.create({
file: attachment,
description: email.subject
})
end
end
end
end
我的怀疑是代替这个功能
def receive(email)
......
end
我如何在自己的功能示例中接收邮件:
def reveiver_mailer
.......
end