正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

受信メール

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab Self-Managed

GitLabには、受信メールメッセージの受信に基づくいくつかの機能があります:

要件

GitLabインスタンス宛てのメッセージのみを受信するメールアドレスを使用することをお勧めします。GitLab宛てではない受信メールメッセージは、リジェクト通知を受け取ります。

受信メールメッセージの処理には、IMAP対応のメールアカウントが必要です。GitLabでは、次の3つの戦略のいずれかが必要です:

  • メールのサブアドレス指定(推奨)
  • すべてをキャッチするメールボックス
  • 専用メールアドレス(メールによる返信のみをサポート)

これらのオプションについて、それぞれ説明します。

メールのサブアドレス指定

サブアドレス指定は、user+arbitrary_tag@example.com宛てのすべてのメールがuser@example.comのメールボックスに届くメールサーバーの機能です。Gmail、Google Apps、Yahoo!などのプロバイダーでサポートされています。Mail、Outlook.com、iCloud、およびPostfixメールサーバー(オンプレミスで実行可能)などがあります。Microsoft Exchange Serverはサブアドレス指定をサポートしていません 。また、Microsoft Office 365はデフォルトでサブアドレス指定をサポートしていません

プロバイダーまたはサーバーがメールのサブアドレス指定をサポートしている場合は、それを使用することをお勧めします。専用メールアドレスは、メールによる返信機能のみをサポートしています。すべてをキャッチするメールボックスはサブアドレス指定と同じ機能をサポートしますが、メールアドレスが1つしか使用されず、すべてをキャッチするメールボックスをGitLab以外の他の目的で使用できるため、サブアドレス指定が推奨されます。

すべてをキャッチするメールボックス

ドメインのすべてをキャッチするメールボックスは、メールサーバーに存在するどのアドレスにも一致しない、そのドメイン宛てのすべてのメールメッセージを受信します。

すべてをキャッチするメールボックスはメールのサブアドレス指定と同じ機能をサポートしていますが、すべてをキャッチするメールボックスを他の目的に予約できるように、メールのサブアドレス指定が引き続き推奨されます。

専用メールアドレス

このソリューションをセットアップするには、ユーザーからのGitLab通知への返信を受信する専用メールアドレスを作成する必要があります。ただし、この方法は返信のみをサポートし、受信メールの他の機能はサポートしません。

許可されるヘッダー

設定されたメールアドレスが次のヘッダーのいずれかに存在する場合、メールは正しく処理されます(チェックされる順にソート):

  • To
  • Delivered-To
  • X-Delivered-To
  • Envelope-ToまたはX-Envelope-To
  • Received
  • X-Original-To
  • X-Forwarded-To
  • Cc

Referencesヘッダーも許可されますが、これは特に既存のディスカッションスレッドにメールの返信を関連付けるために使用されます。これは、メールによるイシューの作成には使用されません。

GitLab 14.6以降では、サービスデスクも許可されるヘッダーをチェックします。

通常、Toフィールドには、プライマリ受信者のメールアドレスが含まれています。ただし、次の場合、設定されたGitLabメールアドレスが含まれていない可能性があります:

  • アドレスがBCCフィールドにある。
  • メールが転送された。

Receivedヘッダーには、複数のメールアドレスを含めることができます。これらは、表示される順にチェックされます。最初の一致が使用されます。

拒否されたヘッダー

自動メールシステムからの不要なイシュー作成を防ぐため、GitLabは次のヘッダーを含むすべての受信メールを無視します:

  • Auto-Submittedno以外の値)。
  • X-Autoreplyyesの値)。

セットアップ

受信メールにGmail / Google Appsを使用する場合は、IMAPアクセスが有効になっていること、安全性の低いアプリからのアカウントへのアクセスを許可していること、または2段階認証をオンにして、アプリケーションパスワードを使用していることを確認してください。

Office 365を使用し、2要素認証が有効になっている場合は、メールボックスの通常のパスワードの代わりにアプリパスワードを使用していることを確認してください。

UbuntuでIMAPアクセスを使用して基本的なPostfixメールサーバーをセットアップするには、Postfixセットアップドキュメントに従ってください。

セキュリティに関する懸念:

受信メールの受信に使用するドメインを選択する際は注意してください。

たとえば、最上位の会社のドメインがhooli.comであるとします。社内のすべての従業員は、Google Workspaceを介してそのドメインにメールアドレスを持っており、会社のプライベートSlackインスタンスにサインアップするには、有効な@hooli.comメールアドレスが必要です。

hooli.comで公開されているGitLabインスタンスもホストし、受信メールドメインをhooli.comに設定すると、攻撃者がSlackにサインアップするときにプロジェクト固有のアドレスをメールとして使用して、メールによるイシューの新規作成またはメールによるマージリクエストの新規作成機能を悪用する可能性があります。これにより確認メールが送信され、攻撃者が所有するプロジェクトに新しいイシューまたはマージリクエストが作成され、確認リンクを選択して会社のプライベートSlackインスタンスでアカウントを検証できるようになります。

incoming.hooli.comのようなサブドメインで受信メールを受信し、*.hooli.com.のようなメールアドレスへのアクセスのみに基づいて認証するサービスを使用しないようにすることをお勧めします。または、hooli-gitlab.comのようなGitLabメール通信専用のドメインを使用します。

この悪用の実例については、GitLabイシュー#30366を参照してください。

スパムを減らすように構成されたメールサーバーを使用してください。たとえば、デフォルト設定で実行されているPostfixメールサーバーは、悪用につながる可能性があります。構成されたメールボックスで受信したすべてのメッセージが処理され、GitLabインスタンス宛てではないメッセージはリジェクト通知を受け取ります。送信者のアドレスがスプーフィングされている場合、リジェクト通知はスプーフィングされたFROMアドレスに配信され、メールサーバーのIPまたはドメインがブロックリストに表示される可能性があります。

ユーザーは、最初に認証するために2要素認証(2FA)を使用しなくても、受信メール機能を使用できます。これは、インスタンスに対して強制2要素認証を有効にしている場合でも当てはまります。

Linuxパッケージインストール

  1. /etc/gitlab/gitlab.rbincoming_emailセクションを見つけて機能を有効にし、特定のIMAPサーバーとメールアカウントの詳細を入力します(以下のを参照)。

  2. 変更を有効にするには、GitLabを再設定してください:

    sudo gitlab-ctl reconfigure
    
    # Needed when enabling or disabling for the first time but not for password changes.
    # See https://gitlab.com/gitlab-org/gitlab-foss/-/issues/23560#note_61966788
    sudo gitlab-ctl restart
  3. すべてが正しく設定されていることを検証します:

    sudo gitlab-rake gitlab:incoming_email:check

メールによる返信が機能するはずです。

自己コンパイルによるインストール

  1. GitLabインストールディレクトリに移動します:

    cd /home/git/gitlab
  2. gitlab-mail_room gemを手動でインストールします:

    gem install gitlab-mail_room

    この手順は、スレッドのデッドロックを回避し、最新のMailRoom機能をサポートするために必要です。

  3. config/gitlab.ymlincoming_emailセクションを見つけて機能を有効にし、特定のIMAPサーバーとメールアカウントの詳細を入力します(以下のを参照)。

systemdユニットを使用してGitLabを管理する場合は、次のようにします:

  1. gitlab-mailroom.servicegitlab.targetへの依存関係として追加します:

    sudo systemctl edit gitlab.target

    開いたエディタで、以下を追加してファイルを保存します:

    [Unit]
    Wants=gitlab-mailroom.service
  2. RedisとPostgreSQLを同じマシンで実行する場合は、Redisへの依存関係を追加する必要があります。以下を実行します:

    sudo systemctl edit gitlab-mailroom.service

    開いたエディタで、以下を追加してファイルを保存します:

    [Unit]
    Wants=redis-server.service
    After=redis-server.service
  3. gitlab-mailroom.serviceを起動します:

    sudo systemctl start gitlab-mailroom.service
  4. すべてが正しく設定されていることを検証します:

    sudo -u git -H bundle exec rake gitlab:incoming_email:check RAILS_ENV=production

SysV initスクリプトを使用してGitLabを管理する場合は、次のようにします:

  1. /etc/default/gitlabのinitスクリプトでmail_roomを有効にします:

    sudo mkdir -p /etc/default
    echo 'mail_room_enabled=true' | sudo tee -a /etc/default/gitlab
  2. GitLabを再起動します:

    sudo service gitlab restart
  3. すべてが正しく設定されていることを検証します:

    sudo -u git -H bundle exec rake gitlab:incoming_email:check RAILS_ENV=production

メールによる返信が機能するはずです。

設定例

Postfix

Postfixメールサーバーの構成例。メールボックスincoming@gitlab.example.comを想定しています。

Linuxパッケージのインストールの例:

gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress+%{key}@gitlab.example.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "incoming+%{key}@gitlab.example.com"

# Email account username
# With third party providers, this is usually the full email address.
# With self-hosted email servers, this is usually the user part of the email address.
gitlab_rails['incoming_email_email'] = "incoming"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "gitlab.example.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 143
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = false
# Whether the IMAP server uses StartTLS
gitlab_rails['incoming_email_start_tls'] = false

# The mailbox where incoming mail will end up. Usually "inbox".
gitlab_rails['incoming_email_mailbox_name'] = "inbox"
# The IDLE command timeout.
gitlab_rails['incoming_email_idle_timeout'] = 60

# If you are using Microsoft Graph instead of IMAP, set this to false to retain
# messages in the inbox because deleted messages are auto-expunged after some time.
gitlab_rails['incoming_email_delete_after_delivery'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
# Only applies to IMAP. Microsoft Graph will auto-expunge any deleted messages.
gitlab_rails['incoming_email_expunge_deleted'] = true

セルフコンパイルインストールの例:

incoming_email:
    enabled: true

    # The email address including the %{key} placeholder that will be replaced to reference the
    # item being replied to. This %{key} should be included in its entirety within the email
    # address and not replaced by another value.
    # For example: emailaddress+%{key}@gitlab.example.com.
    # The placeholder must appear in the "user" part of the address (before the `@`).
    address: "incoming+%{key}@gitlab.example.com"

    # Email account username
    # With third party providers, this is usually the full email address.
    # With self-hosted email servers, this is usually the user part of the email address.
    user: "incoming"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "gitlab.example.com"
    # IMAP server port
    port: 143
    # Whether the IMAP server uses SSL
    ssl: false
    # Whether the IMAP server uses StartTLS
    start_tls: false

    # The mailbox where incoming mail will end up. Usually "inbox".
    mailbox: "inbox"
    # The IDLE command timeout.
    idle_timeout: 60

    # If you are using Microsoft Graph instead of IMAP, set this to false to retain
    # messages in the inbox because deleted messages are auto-expunged after some time.
    delete_after_delivery: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    # Only applies to IMAP. Microsoft Graph will auto-expunge any deleted messages.
    expunge_deleted: true

Gmail

Gmail / Google Workspaceの構成例。メールボックスgitlab-incoming@gmail.comを想定しています。

incoming_email_emailはGmailエイリアスアカウントにできません。

Linuxパッケージのインストールの例:

gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress+%{key}@gmail.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "gitlab-incoming+%{key}@gmail.com"

# Email account username
# With third party providers, this is usually the full email address.
# With self-hosted email servers, this is usually the user part of the email address.
gitlab_rails['incoming_email_email'] = "gitlab-incoming@gmail.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "imap.gmail.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true
# Whether the IMAP server uses StartTLS
gitlab_rails['incoming_email_start_tls'] = false

# The mailbox where incoming mail will end up. Usually "inbox".
gitlab_rails['incoming_email_mailbox_name'] = "inbox"
# The IDLE command timeout.
gitlab_rails['incoming_email_idle_timeout'] = 60

# If you are using Microsoft Graph instead of IMAP, set this to false if you want to retain
# messages in the inbox because deleted messages are auto-expunged after some time.
gitlab_rails['incoming_email_delete_after_delivery'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
# Only applies to IMAP. Microsoft Graph will auto-expunge any deleted messages.
gitlab_rails['incoming_email_expunge_deleted'] = true

セルフコンパイルインストールの例:

incoming_email:
    enabled: true

    # The email address including the %{key} placeholder that will be replaced to reference the
    # item being replied to. This %{key} should be included in its entirety within the email
    # address and not replaced by another value.
    # For example: emailaddress+%{key}@gmail.com.
    # The placeholder must appear in the "user" part of the address (before the `@`).
    address: "gitlab-incoming+%{key}@gmail.com"

    # Email account username
    # With third party providers, this is usually the full email address.
    # With self-hosted email servers, this is usually the user part of the email address.
    user: "gitlab-incoming@gmail.com"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "imap.gmail.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true
    # Whether the IMAP server uses StartTLS
    start_tls: false

    # The mailbox where incoming mail will end up. Usually "inbox".
    mailbox: "inbox"
    # The IDLE command timeout.
    idle_timeout: 60

    # If you are using Microsoft Graph instead of IMAP, set this to falseto retain
    # messages in the inbox because deleted messages are auto-expunged after some time.
    delete_after_delivery: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    # Only applies to IMAP. Microsoft Graph will auto-expunge any deleted messages.
    expunge_deleted: true

Microsoft Exchange Server

IMAPが有効になっているMicrosoft Exchange Serverの構成例。Exchangeはサブアドレス指定をサポートしていないため、次の2つのオプションのみが存在します:

すべてをキャッチするメールボックス

すべてをキャッチするメールボックスincoming@exchange.example.comを想定しています。

Linuxパッケージのインストールの例:

gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress-%{key}@exchange.example.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
# Exchange does not support sub-addressing, so a catch-all mailbox must be used.
gitlab_rails['incoming_email_address'] = "incoming-%{key}@exchange.example.com"

# Email account username
# Typically this is the userPrincipalName (UPN)
gitlab_rails['incoming_email_email'] = "incoming@ad-domain.example.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "exchange.example.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
# Only applies to IMAP. Microsoft Graph will auto-expunge any deleted messages.
gitlab_rails['incoming_email_expunge_deleted'] = true

セルフコンパイルインストールの例:

incoming_email:
    enabled: true

    # The email address including the %{key} placeholder that will be replaced to reference the
    # item being replied to. This %{key} should be included in its entirety within the email
    # address and not replaced by another value.
    # For example: emailaddress-%{key}@exchange.example.com.
    # The placeholder must appear in the "user" part of the address (before the `@`).
    # Exchange does not support sub-addressing, so a catch-all mailbox must be used.
    address: "incoming-%{key}@exchange.example.com"

    # Email account username
    # Typically this is the userPrincipalName (UPN)
    user: "incoming@ad-domain.example.com"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "exchange.example.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true

    # If you are using Microsoft Graph instead of IMAP, set this to false to retain
    # messages in the inbox because deleted messages are auto-expunged after some time.
    delete_after_delivery: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    expunge_deleted: true
専用メールアドレス

メールによる返信のみをサポートします。サービスデスクをサポートできません。

専用メールアドレスincoming@exchange.example.comを想定しています。

Linuxパッケージのインストールの例:

gitlab_rails['incoming_email_enabled'] = true

# Exchange does not support sub-addressing, and we're not using a catch-all mailbox so %{key} is not used here
gitlab_rails['incoming_email_address'] = "incoming@exchange.example.com"

# Email account username
# Typically this is the userPrincipalName (UPN)
gitlab_rails['incoming_email_email'] = "incoming@ad-domain.example.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "exchange.example.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
gitlab_rails['incoming_email_expunge_deleted'] = true

セルフコンパイルインストールの例:

incoming_email:
    enabled: true

    # Exchange does not support sub-addressing,
    # and we're not using a catch-all mailbox so %{key} is not used here
    address: "incoming@exchange.example.com"

    # Email account username
    # Typically this is the userPrincipalName (UPN)
    user: "incoming@ad-domain.example.com"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "exchange.example.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true

    # If you are using Microsoft Graph instead of IMAP, set this to false to retain
    # messages in the inbox because deleted messages are auto-expunged after some time.
    delete_after_delivery: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    expunge_deleted: true

Microsoft Office 365

IMAPが有効になっているMicrosoft Office 365の構成例。

サブアドレス指定メールボックス

2020年9月以降、サブアドレス指定のサポートがOffice 365に追加されました。この機能はデフォルトでは有効になっておらず、PowerShellを使用して有効にする必要があります。

この一連のPowerShellコマンドは、Office 365の組織レベルでサブアドレス指定を有効にします。これにより、組織内のすべてのメールボックスがサブアドレス指定されたメールを受信できるようになります。

サブアドレス指定を有効にするには:

  1. PowerShellギャラリーからExchangeOnlineManagementモジュールをダウンロードしてインストールします。

  2. PowerShellで、次のコマンドを実行します:

    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    Import-Module ExchangeOnlineManagement
    Connect-ExchangeOnline
    Set-OrganizationConfig -DisablePlusAddressInRecipients $false
    Disconnect-ExchangeOnline

このLinuxパッケージインストールの例では、メールボックスincoming@office365.example.comを想定しています:

gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress+%{key}@office365.example.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "incoming+%{key}@office365.example.com"

# Email account username
# Typically this is the userPrincipalName (UPN)
gitlab_rails['incoming_email_email'] = "incoming@office365.example.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "outlook.office365.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
gitlab_rails['incoming_email_expunge_deleted'] = true

このセルフコンパイルインストールの例では、メールボックスincoming@office365.example.comを想定しています:

incoming_email:
    enabled: true

    # The email address including the %{key} placeholder that will be replaced to reference the
    # item being replied to. This %{key} should be included in its entirety within the email
    # address and not replaced by another value.
    # For example: emailaddress+%{key}@office365.example.com.
    # The placeholder must appear in the "user" part of the address (before the `@`).
    address: "incoming+%{key}@office365.example.comm"

    # Email account username
    # Typically this is the userPrincipalName (UPN)
    user: "incoming@office365.example.comm"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "outlook.office365.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    expunge_deleted: true
すべてをキャッチするメールボックス

このLinuxパッケージインストールの例では、すべてをキャッチするメールボックスincoming@office365.example.comを想定しています:

gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress-%{key}@office365.example.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "incoming-%{key}@office365.example.com"

# Email account username
# Typically this is the userPrincipalName (UPN)
gitlab_rails['incoming_email_email'] = "incoming@office365.example.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "outlook.office365.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
gitlab_rails['incoming_email_expunge_deleted'] = true

このセルフコンパイルインストールの例では、すべてをキャッチするメールボックスincoming@office365.example.comを想定しています:

incoming_email:
    enabled: true

    # The email address including the %{key} placeholder that will be replaced to reference the
    # item being replied to. This %{key} should be included in its entirety within the email
    # address and not replaced by another value.
    # For example: emailaddress+%{key}@office365.example.com.
    # The placeholder must appear in the "user" part of the address (before the `@`).
    address: "incoming-%{key}@office365.example.com"

    # Email account username
    # Typically this is the userPrincipalName (UPN)
    user: "incoming@ad-domain.example.com"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "outlook.office365.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    expunge_deleted: true
専用メールアドレス

メールによる返信のみをサポートします。サービスデスクをサポートできません。

このLinuxパッケージインストールの例では、専用メールアドレスincoming@office365.example.comを想定しています:

gitlab_rails['incoming_email_enabled'] = true

gitlab_rails['incoming_email_address'] = "incoming@office365.example.com"

# Email account username
# Typically this is the userPrincipalName (UPN)
gitlab_rails['incoming_email_email'] = "incoming@office365.example.com"
# Email account password
gitlab_rails['incoming_email_password'] = "[REDACTED]"

# IMAP server host
gitlab_rails['incoming_email_host'] = "outlook.office365.com"
# IMAP server port
gitlab_rails['incoming_email_port'] = 993
# Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true

# Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
gitlab_rails['incoming_email_expunge_deleted'] = true

このセルフコンパイルインストールの例では、専用メールアドレスincoming@office365.example.comを想定しています:

incoming_email:
    enabled: true

    address: "incoming@office365.example.com"

    # Email account username
    # Typically this is the userPrincipalName (UPN)
    user: "incoming@office365.example.com"
    # Email account password
    password: "[REDACTED]"

    # IMAP server host
    host: "outlook.office365.com"
    # IMAP server port
    port: 993
    # Whether the IMAP server uses SSL
    ssl: true

    # Whether to expunge (permanently remove) messages from the mailbox when they are marked as deleted after delivery
    expunge_deleted: true

Microsoft Graph

GitLabは、IMAPの代わりにMicrosoft Graph APIを使用して受信メールを読み取りできます。MicrosoftがBasic認証でのIMAPの使用を非推奨にしているため、新しいMicrosoft Exchange OnlineメールボックスにはMicrosoft Graph APIが必要になります。

Microsoft Graph用にGitLabを構成するには、すべてのメールボックスに対するMail.ReadWrite権限を持つOAuth 2.0アプリケーションをAzure Activeディレクトリに登録する必要があります。詳細については、MailRoomステップバイステップガイドおよびMicrosoftの説明を参照してください。

OAuth 2.0アプリケーションを構成するときは、以下を記録してください:

  • Azure ActiveディレクトリのテナントID
  • OAuth 2.0アプリケーションのクライアントID
  • OAuth 2.0アプリケーションのクライアントのシークレットキー
メールボックスアクセスの制限

MailRoomをサービスアカウントとして機能させるには、Azure Activeディレクトリに作成するアプリケーションで、すべてのメールボックスでメールを読み取り/書き込みするためのMail.ReadWriteプロパティを設定する必要があります。

セキュリティ上の懸念を軽減するために、Microsoftドキュメントで説明されているように、すべてのアカウントのメールボックスアクセスを制限するアプリケーションアクセスポリシーを構成することをお勧めします。

このLinuxパッケージインストールの例では、次のメールボックスを使用していることを前提としています:incoming@example.onmicrosoft.com:

Microsoft Graphを設定する
gitlab_rails['incoming_email_enabled'] = true

# The email address including the %{key} placeholder that will be replaced to reference the
# item being replied to. This %{key} should be included in its entirety within the email
# address and not replaced by another value.
# For example: emailaddress+%{key}@example.onmicrosoft.com.
# The placeholder must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "incoming+%{key}@example.onmicrosoft.com"

# Email account username
gitlab_rails['incoming_email_email'] = "incoming@example.onmicrosoft.com"
gitlab_rails['incoming_email_delete_after_delivery'] = false

gitlab_rails['incoming_email_inbox_method'] = 'microsoft_graph'
gitlab_rails['incoming_email_inbox_options'] = {
   'tenant_id': '<YOUR-TENANT-ID>',
   'client_id': '<YOUR-CLIENT-ID>',
   'client_secret': '<YOUR-CLIENT-SECRET>',
   'poll_interval': 60  # Optional
}

米国政府機関向けMicrosoft Cloudまたは他のAzureデプロイの場合は、azure_ad_endpointおよびgraph_endpoint設定を構成します。

  • 米国政府機関向けMicrosoft Cloudの例:
gitlab_rails['incoming_email_inbox_options'] = {
   'azure_ad_endpoint': 'https://login.microsoftonline.us',
   'graph_endpoint': 'https://graph.microsoft.us',
   'tenant_id': '<YOUR-TENANT-ID>',
   'client_id': '<YOUR-CLIENT-ID>',
   'client_secret': '<YOUR-CLIENT-SECRET>',
   'poll_interval': 60  # Optional
}

Microsoft Graph APIは、セルフコンパイルインストールではまだサポートされていません。詳細については、こちらのイシューを参照してください。

暗号化された認証情報を使用する

受信認証情報を設定ファイルに平文で保存する代わりに、オプションで暗号化されたファイルを使用することもできます。

前提要件:

  • 暗号化された認証情報を使用するには、まず暗号化設定を有効にする必要があります。

暗号化されたファイルでサポートされている設定項目は次のとおりです:

  • user
  • password
  1. 最初に/etc/gitlab/gitlab.rbの受信メール構成が次のようになっている場合:

    gitlab_rails['incoming_email_email'] = "incoming-email@mail.example.com"
    gitlab_rails['incoming_email_password'] = "examplepassword"
  2. 暗号化されたシークレットを編集します:

    sudo gitlab-rake gitlab:incoming_email:secret:edit EDITOR=vim
  3. 受信メールシークレットの暗号化されていない内容を入力します:

    user: 'incoming-email@mail.example.com'
    password: 'examplepassword'
  4. /etc/gitlab/gitlab.rbを編集し、incoming_emailemailpasswordの設定を削除します。

  5. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure

Kubernetesシークレットを使用して、受信メールパスワードを格納します。詳細については、Helm IMAPシークレットを参照してください。

  1. 最初にdocker-compose.ymlの受信メール構成が次のようになっている場合:

    version: "3.6"
    services:
      gitlab:
        image: 'gitlab/gitlab-ee:latest'
        restart: always
        hostname: 'gitlab.example.com'
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['incoming_email_email'] = "incoming-email@mail.example.com"
            gitlab_rails['incoming_email_password'] = "examplepassword"
  2. コンテナ内に入り、暗号化されたシークレットを編集します:

    sudo docker exec -t <container_name> bash
    gitlab-rake gitlab:incoming_email:secret:edit EDITOR=editor
  3. 受信メールシークレットの暗号化されていない内容を入力します:

    user: 'incoming-email@mail.example.com'
    password: 'examplepassword'
  4. docker-compose.ymlを編集し、incoming_emailemailpasswordの設定を削除します。

  5. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. 最初に/home/git/gitlab/config/gitlab.ymlの受信メール構成が次のようになっている場合:

    production:
      incoming_email:
        user: 'incoming-email@mail.example.com'
        password: 'examplepassword'
  2. 暗号化されたシークレットを編集します:

    bundle exec rake gitlab:incoming_email:secret:edit EDITOR=vim RAILS_ENVIRONMENT=production
  3. 受信メールシークレットの暗号化されていない内容を入力します:

    user: 'incoming-email@mail.example.com'
    password: 'examplepassword'
  4. /home/git/gitlab/config/gitlab.ymlを編集し、incoming_email:userpasswordの設定を削除します。

  5. ファイルを保存してGitLabとMailroomを再起動します

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

トラブルシューティング

16.6.0でメールの取り込みが機能しない

GitLab 16.6では、リグレッションにより、mail_room(メールの取り込み)が起動しません。サービスデスクやその他のメールによる返信機能は動作しません。このイシューは16.6.1で修正されました。詳細については、432257のイシューを参照してください。

この回避策では、影響を受けるファイルをパッチするために、GitLabインストールで次のコマンドを実行します:

curl --output /tmp/mailroom.patch --url "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137279.diff"
patch -p1 -d /opt/gitlab/embedded/service/gitlab-rails < /tmp/mailroom.patch
gitlab-ctl restart mailroom
curl --output /tmp/mailroom.patch --url "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137279.diff"
cd /opt/gitlab/embedded/service/gitlab-rails
patch -p1 < /tmp/mailroom.patch
gitlab-ctl restart mailroom

メールアドレス制限のあるプロバイダーによって受信メールが拒否される

一部のメールプロバイダーでは、メールアドレスのローカル部分(@の前)に64文字の制限が課せられているため、GitLabインスタンスが受信メールを受信しない可能性があります。この制限を超えるアドレスからのすべてのメールは、拒否されたメールです。

回避策として、短いパスを維持してください:

  • incoming_email_address%{key}の前に構成されたローカル部分が、できるだけ短く、31文字を超えないようにしてください。
  • 指定されたプロジェクトを、より高いグループ階層に配置します。
  • グループプロジェクトの名前をより短い名前に変更します。

460206のイシューでこの機能を追跡する。