我已经安装并运行了Redmine2.2.1,但是我无法让通知邮件正常工作。我一直得到以下错误:

An error occurred while sending mail (getaddrinfo: Name or service not known)

我不知道我错过了什么。我遵循这些instructions来使用gmail设置电子邮件通知,但似乎不管我对configuration.yml文件做了什么更改,我仍然会收到相同的错误。
这就是我的configuration.xml文件的外观:
production:
email_delivery:
  delivery_method: :smtp
smtp_settings:
  tls: true
  enable_starttls_auto: true
  address: "smtp.gmail.com"
  port: 587
  domain: "smtp.gmail.com"
  authentication: :plain
  user_name: "[email protected]"
  password: "mypassword"

其他的都被删掉了。
我尝试更改和删除tlsenable_starttls_auto选项,但对configuration.yml文件的更改不会影响错误消息。
我还检查了在其他论坛上发现的常见错误,如配置文件中的选项卡或两次定义的production:config,等等。
我在gmail帐户上启用了smtp。
我也试过设置ActionMailer,但我不确定该怎么做,或者我是否需要这样做。在任何地方都没有提到这一点。我已经安装好了,但不确定这是否有什么作用。
Redmine 2.2.1
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
Rails 3.2.11
gem version 1.8.24
Amazon AMI Linux

生产日志:
Started GET "/redmine/admin/test_email" for 98.xxx.xx.xx at Wed Jan 16 12:28:23 -0800     2013
Processing by AdminController#test_email as HTML
  Current user: oscarm (id=3)
  Rendered mailer/test_email.text.erb within layouts/mailer (0.1ms)
Redirected to http://mydomain/redmine/settings   /edit?tab=notifications
Completed 302 Found in 35ms (ActiveRecord: 0.7ms)
Started GET "/redmine/settings/edit?tab=notifications" for 98.xxx.xx.xx at Wed Jan 16 12:28:23 -0800 2013
Processing by SettingsController#edit as HTML
Parameters: {"tab"=>"notifications"}
Current user: oscarm (id=3)
Rendered settings/_general.html.erb (6.8ms)
Rendered settings/_display.html.erb (9.0ms)
Rendered settings/_authentication.html.erb (5.9ms)
Rendered settings/_projects.html.erb (5.9ms)
Rendered queries/_columns.html.erb (6.5ms)
Rendered settings/_issues.html.erb (12.6ms)
Rendered settings/_notifications.html.erb (6.4ms)
Rendered settings/_mail_handler.html.erb (1.9ms)
Rendered settings/_repositories.html.erb (10.3ms)
Rendered common/_tabs.html.erb (66.2ms)
Rendered settings/edit.html.erb within layouts/admin (67.0ms)
Rendered admin/_menu.html.erb (5.6ms)
Rendered layouts/base.html.erb (19.3ms)
Completed 200 OK in 222ms (Views: 91.3ms | ActiveRecord: 4.3ms)

最佳答案

所以我知道我的问题是…
我一直在修改configuration.yml文件,并期望redmine在每次重新加载页面时都会读取它,但事实并非如此。redmine只在启动时读取配置文件,因此每次更改配置文件时,我都必须重新启动redmine。
我试过的一件事是在redmine/plugin中安装action_mailer_optional_tls插件,但我最终发现这个插件只适用于ruby 1.8.6,我使用的ruby 1.8.7内置了这个功能。从redmine/plugin删除action_mailer_optional_tls目录并重新启动redmine后,我可以发送通知电子邮件:-)
下面是我的最终配置,让redmine在gmail上工作:

production:
  email_delivery:
    delivery_method: :smtp
  smtp_settings:
    address: "smtp.gmail.com"
    port: 587
    domain: "smtp.gmail.com"
    authentication: :plain
    user_name: "[email protected]"
    password: "mypassword"
    enable_starttls_auto: true

希望这能帮助有同样问题的人。

关于ruby - 通知电子邮件在使用SMTP和Gmail的Redmine上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14367297/

10-14 04:57