Rails3 ActionMailer在开发环境中交付

时间:2011-09-30 01:04:32

标签: ruby-on-rails-3 development-environment actionmailer

是否可以在开发环境中发送邮件程序?

我已将此添加到我的development.rb文件中:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true

ActionMailer::Base.smtp_settings = {
  :address              => "mail.email.com",
  :port                 => 25,
  :domain               => 'email.com',
  :user_name            => 'email@email.com',
  :password             => 'password',
  :authentication       => 'plain',
  :enable_starttls_auto => true  }

然后我在rails控制台中运行UserMailer.welcome_email(@user).deliver,它返回#<Mail::Message:2265713480, Multipart: true, Headers: <Date: Thu...但我从未收到过该电子邮件。还有其他我需要配置的东西吗?

哦,如果我检查ActionMailer::Base.deliveries,它会返回一个空哈希=> []

1 个答案:

答案 0 :(得分:1)

需要将以下内容添加到environments/development.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true