在联系表单中,用户填写他们的姓名和电子邮件以及消息的字段。
class ContactForm < MailForm::Base
attribute :name, :validate => true
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
attribute :message
attribute :nickname, :captcha => true
# Declare the e-mail headers. It accepts anything the mail method
# in ActionMailer accepts.
def headers
{
:subject => "My Contact Form",
:to => "FILLTHISIN@example.com",
:from => %("#{name}" <#{email}>)
}
end
end
我想从user.email
属性自动发送,而不是让用户填写字段。这可能吗?