LoginSignup
21

More than 5 years have passed since last update.

Redmine2.4 + Gmail連携の設定 (BitNami/CentOS)

Last updated at Posted at 2014-03-10

前回RedmineとGit連携について書きましたが、今回はRedmineとGmailの連携です。
今回も結構ハマったので今後の参考になれば。。

環境(バージョン)

Redmineのバージョンによって結構違うようなので注意してください。

  • CentOS 6.3 (on Windows Azure)
  • Redmine 2.4.3.stable
  • Ruby 1.9.3-p484 (2013-11-22) [x86_64-linux]
  • Rails 3.2.16

RedmineはBitNamiのオールインワンインストーラーで入れていますが、Bitnami特有の面は少ないと思います。

※Redmineが提供しているaboutスクリプトで各種のバージョン確認できます。

$ sudo /opt/redmine-2.4.3-0/ruby/bin/ruby /opt/redmine-2.4.3-0/apps/redmine/htdocs/script/about

sh: darcs: command not found
sh: hg: command not found
sh: bzr: command not found
Environment:
  Redmine version                2.4.3.stable
  Ruby version                   1.9.3-p484 (2013-11-22) [x86_64-linux]
  Rails version                  3.2.16
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.5
  Git                            1.8.5.3.321
  Filesystem
Redmine plugins:
  no plugin installed

Redmine側の設定

1. configuration.yml編集

default:のemail_delivery:項目を編集します。編集したらapcheを再起動。

$ vi /opt/redmine-2.4.3-0/apps/redmine/htdocs/config/configuration.yml

# default configuration options for all environments
default:
  # Outgoing emails configuration (see examples above)
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: "smtp.gmail.com"
      port: 587
      domain: "smtp.gmail.com"
      authentication: :plain
      user_name: "Gmailのアドレス"
      password: "Gmailのパスワード"

BitNamiの場合はctlscript.shスクリプトで。
shell-session
$ sudo /opt/redmine-2.4.3-0/ctlscript.sh restart apache
Syntax OK
/opt/redmine-2.4.3-0/apache2/scripts/ctl.sh : httpd stopped
Syntax OK
/opt/redmine-2.4.3-0/apache2/scripts/ctl.sh : httpd started at port 80
$

(参考)
BitNami Redmine - Bitnami documentation
http://wiki.bitnami.com/Applications/BitNami_Redmine#How_to_configure_the_email_settings_of_Redmine.3f
「enable_starttls_auto プロパティが無いと "(530 5.7.0 Must issue a STARTTLS command first ..."ってエラーメッセージが表示されるよ」、と書いてあります。

参考にしたけど、バージョン違いとかで適用外だったもの

Redmine(2.0.3)の通知メールをGmail経由で送ろうとしてハマったというブログ記事では、authentication: :loginに変更とありましたが、authentication: :plainで大丈夫でした。また、tls: trueを削除という記述がありますが、本環境では元々tls: の行は無かったのでRedmineのバージョンの違いかもしれません。

GMailのSMTPサーバをRedmineで使うというブログ記事では、action_mailer_optional_tls pluginについて触れられていますが、これはruby1.8のもの。Ruby 1.9 + Rails 3 + Gmailでtlsmailは必要なくなりましただそうです。

Gmail側の設定

1. アクティビティのアラート(ブロック)を解除する

Gmailでは、プログラム等からのアクセスがあると不正利用の可能性からブロックされ、不審なアカウント アクティビティの通知が送られます。
不審なアクティビティのアラート - Google アカウント ヘルプ
https://support.google.com/accounts/answer/1144110?hl=ja
Gmailの受信箱にこんなメールも来ます。
gmail_block.png

この場合、以下の手順で解除します。

gmail_block2.png

2. キャプチャ画像認証を解除する

今回最大のハマリポイントでした。Redmineのテストメール送信で”(534-5.7.14”というエラーになる場合、この設定が必要になると思います。

(参考)
Test notification mail send results in broken error message "error sending (534-5.7.14" - Bitnami Community
http://community.bitnami.com/t/test-notification-mail-send-results-in-broken-error-message-error-sending-534-5-7-14/20719/7

クライアントでユーザー名とパスワードが受け入れられない - Gmail ヘルプ
https://support.google.com/mail/answer/14257

Redmine上からテストメール送信

  • Redmineの「管理」→「設定」→「メール通知」タブにて
  • 送信元メールアドレスにGmailアドレスを設定。その他、ヘッダ/フッタ等を設定。
  • 画面下部の「テストメール送信」をクリック。 無事にテストメールが送信されれば完了です。

Redmine.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21