Rails:填写联系表后发送电子邮件

时间:2015-05-22 11:23:19

标签: ruby-on-rails actionmailer mail-form

我想使用this教程

创建联系表单

最后写的是我应该配置SMTP,所以在config / environments / developement.rb中我设置

 config.action_mailer.default_url_options = {:host => 'myproject.c9.io'}

(我在c9.io上使用rails)

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "gmail.com",
  :user_name            => "myusername",
  :password             => "mypassword",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

我是铁杆,特别是发送电子邮件的新手,所以我想问一下,因为当我填写表格并发送时,我的电子邮件地址没有收到消息,我该怎么办才能得到确认正确的发送。我知道互联网上有很多教程,但现在我处于困境中,所以我很感激解释。

1 个答案:

答案 0 :(得分:3)

将这些配置添加到您的development.rb reference

config.action_mailer.default_url_options = {:host => 'myproject.c9.io'}

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'gmail.com',
  user_name:            'myusername',
  password:             'mypassword',
  authentication:       'plain',
  enable_starttls_auto: true  
}