簡體   English   中英

Ruby on Rails-聯系表單不起作用

[英]Ruby on Rails - contact form is not working

我跟隨該網站在Rails應用程序中填寫聯系表。 我在Rails應用程序中使用了空白的引導模板。

https://rubyonrailshelp.wordpress.com/2014/01/08/rails-4-simple-form-and-mail-form-to-make-contact-form/

我唯一的區別是在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM