关于Rails 3:Rails 3-sendgrid设置以支持devise

Rails 3 - sendgrid setup to support devise

我正在尝试使用Devise在我的Rails 3 App上运行sendgrid,因此devise可以发送注册电子邮件等。

我添加了以下内容config / setup_mail.rb:

1
2
3
4
5
6
7
8
ActionMailer::Base.smtp_settings = {
  :address =>"smtp.sendgrid.net",
  :port => '25',
  :domain =>"XXXXXXXXX.com",
  :authentication => :plain,
  :user_name =>"[email protected]",
  :password =>"XXXXXXXXXX"
}

对于Rails Devise发送注册电子邮件还不够吗?还是我需要其他东西或某种ruby?

日志显示正在生成的电子邮件,但我在日志中未看到有关成功发送或出错的MAIL的任何内容。而且我的sendgrid帐户仍然显示0/200封电子邮件已发送。

Rails中是否有更好的方法来查看尝试发送电子邮件时发生的情况?

谢谢


您可以删除现有的设置。

1
heroku addons:create sendgrid:free

这是使用heroku配置电子邮件所需要的唯一代码。

请确保您已经设置了主机链接,我认为您已经进行了设置,因为这将导致它崩溃,但是如果没有,请执行以下操作:

1
config.action_mailer.default_url_options = { :host => 'myapp.heroku.com' }

实际上,这最后的留置权在rails3上有所不同,因此请注意:)

" config"行需要添加到您的" production.rb"文件中。


我正在寻找相同的答案。在intializers / devise.rb中,我读:

1
2
  # Configure the class responsible to send e-mails.
  # config.mailer ="Devise::Mailer"

我想知道是否必须告知Devise使用Actionmailer。