我们可以在ruby on rails上通过开发模式发送电子邮件吗?

时间:2014-02-09 14:51:21

标签: ruby-on-rails email

我在我的应用程序中使用actionmailer进行电子邮件服务,但我很困惑,我们可以通过ruby-on-rails中的开发模式发送电子邮件,或者我们只能通过生产模式发送电子邮件。

1 个答案:

答案 0 :(得分:2)

您可以通过开发和已配置的任何环境发送电子邮件,因为您已配置环境的配置。我倾向于在开发模式中使用gmail来简化。

示例如下,我将添加到我的config/environments/development.rb

  config.action_mailer.default_url_options = {:host => 'localhost:8080'}
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :domain               => 'example.com',
    :user_name            => ENV['GMAIL_ADDRESS'],
    :password             => ENV['GMAIL_PASSWORD'],
    :authentication       => 'plain',
    :enable_starttls_auto => true
  }

http://guides.rubyonrails.org/action_mailer_basics.html