[英]Ruby on Rails - contact form is not working
我跟隨該網站在Rails應用程序中填寫聯系表。 我在Rails應用程序中使用了空白的引導模板。
我唯一的區別是在contact.rb中添加了我的電子郵件
class Contact < MailForm::Base
attribute :name, :validate => true
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w] {2,})\z/i
attribute :message
attribute :nickname, :captcha => true
def headers
{
:subject => "My Contact Form",
:to => "here I added my email",
:from => %("#{name}" <#{email}>)
}
end
end
當我運行本地主機時,一切似乎都可以正常工作,甚至出現消息,並說電子郵件已發送。 但是,當我檢查電子郵件時,收件箱中找不到任何內容。
在開發機器上,Rails中的默認設置是不傳遞郵件,因此您必須將config.action_mailer.perform_deliveries
設置為true。 在這里查看: http : //guides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.