受信メール
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab Self-Managed
GitLabには、受信メールメッセージの受信に基づくいくつかの機能があります:
- メールによる返信:GitLabユーザーがイシューとマージリクエストについて、通知メールに返信することでコメントできるようにします。
- メールによるイシューの新規作成:GitLabユーザーが、ユーザー固有のメールアドレスにメールを送信することで、新しいイシューを作成できるようにします。
- メールによるマージリクエストの新規作成:GitLabユーザーが、ユーザー固有のメールアドレスにメールを送信することで、新しいマージリクエストを作成できるようにします。
- サービスデスク: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通知への返信を受信する専用メールアドレスを作成する必要があります。ただし、この方法は返信のみをサポートし、受信メールの他の機能はサポートしません。
許可されるヘッダー
設定されたメールアドレスが次のヘッダーのいずれかに存在する場合、メールは正しく処理されます(チェックされる順にソート):
ToDelivered-ToX-Delivered-ToEnvelope-ToまたはX-Envelope-ToReceivedX-Original-ToX-Forwarded-ToCc
Referencesヘッダーも許可されますが、これは特に既存のディスカッションスレッドにメールの返信を関連付けるために使用されます。これは、メールによるイシューの作成には使用されません。
GitLab 14.6以降では、サービスデスクも許可されるヘッダーをチェックします。
通常、Toフィールドには、プライマリ受信者のメールアドレスが含まれています。ただし、次の場合、設定されたGitLabメールアドレスが含まれていない可能性があります:
- アドレスが
BCCフィールドにある。 - メールが転送された。
Receivedヘッダーには、複数のメールアドレスを含めることができます。これらは、表示される順にチェックされます。最初の一致が使用されます。
拒否されたヘッダー
自動メールシステムからの不要なイシュー作成を防ぐため、GitLabは次のヘッダーを含むすべての受信メールを無視します:
Auto-Submitted(no以外の値)。X-Autoreply(yesの値)。
セットアップ
受信メールに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パッケージインストール
/etc/gitlab/gitlab.rbのincoming_emailセクションを見つけて機能を有効にし、特定のIMAPサーバーとメールアカウントの詳細を入力します(以下の例を参照)。変更を有効にするには、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すべてが正しく設定されていることを検証します:
sudo gitlab-rake gitlab:incoming_email:check
メールによる返信が機能するはずです。
自己コンパイルによるインストール
GitLabインストールディレクトリに移動します:
cd /home/git/gitlabgitlab-mail_roomgemを手動でインストールします:gem install gitlab-mail_roomこの手順は、スレッドのデッドロックを回避し、最新のMailRoom機能をサポートするために必要です。
config/gitlab.ymlのincoming_emailセクションを見つけて機能を有効にし、特定のIMAPサーバーとメールアカウントの詳細を入力します(以下の例を参照)。
systemdユニットを使用してGitLabを管理する場合は、次のようにします:
gitlab-mailroom.serviceをgitlab.targetへの依存関係として追加します:sudo systemctl edit gitlab.target開いたエディタで、以下を追加してファイルを保存します:
[Unit] Wants=gitlab-mailroom.serviceRedisとPostgreSQLを同じマシンで実行する場合は、Redisへの依存関係を追加する必要があります。以下を実行します:
sudo systemctl edit gitlab-mailroom.service開いたエディタで、以下を追加してファイルを保存します:
[Unit] Wants=redis-server.service After=redis-server.servicegitlab-mailroom.serviceを起動します:sudo systemctl start gitlab-mailroom.serviceすべてが正しく設定されていることを検証します:
sudo -u git -H bundle exec rake gitlab:incoming_email:check RAILS_ENV=production
SysV initスクリプトを使用してGitLabを管理する場合は、次のようにします:
/etc/default/gitlabのinitスクリプトでmail_roomを有効にします:sudo mkdir -p /etc/default echo 'mail_room_enabled=true' | sudo tee -a /etc/default/gitlabGitLabを再起動します:
sudo service gitlab restartすべてが正しく設定されていることを検証します:
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: trueGmail
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: trueMicrosoft Exchange Server
IMAPが有効になっているMicrosoft Exchange Serverの構成例。Exchangeはサブアドレス指定をサポートしていないため、次の2つのオプションのみが存在します:
- すべてをキャッチするメールボックス(Exchange専用に推奨)
- 専用メールアドレス(メールによる返信のみをサポート)
すべてをキャッチするメールボックス
すべてをキャッチするメールボックス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: trueMicrosoft Office 365
IMAPが有効になっているMicrosoft Office 365の構成例。
サブアドレス指定メールボックス
2020年9月以降、サブアドレス指定のサポートがOffice 365に追加されました。この機能はデフォルトでは有効になっておらず、PowerShellを使用して有効にする必要があります。
この一連のPowerShellコマンドは、Office 365の組織レベルでサブアドレス指定を有効にします。これにより、組織内のすべてのメールボックスがサブアドレス指定されたメールを受信できるようになります。
サブアドレス指定を有効にするには:
PowerShellギャラリーから
ExchangeOnlineManagementモジュールをダウンロードしてインストールします。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: trueMicrosoft 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は、セルフコンパイルインストールではまだサポートされていません。詳細については、こちらのイシューを参照してください。
暗号化された認証情報を使用する
受信認証情報を設定ファイルに平文で保存する代わりに、オプションで暗号化されたファイルを使用することもできます。
前提要件:
- 暗号化された認証情報を使用するには、まず暗号化設定を有効にする必要があります。
暗号化されたファイルでサポートされている設定項目は次のとおりです:
userpassword
最初に
/etc/gitlab/gitlab.rbの受信メール構成が次のようになっている場合:gitlab_rails['incoming_email_email'] = "incoming-email@mail.example.com" gitlab_rails['incoming_email_password'] = "examplepassword"暗号化されたシークレットを編集します:
sudo gitlab-rake gitlab:incoming_email:secret:edit EDITOR=vim受信メールシークレットの暗号化されていない内容を入力します:
user: 'incoming-email@mail.example.com' password: 'examplepassword'/etc/gitlab/gitlab.rbを編集し、incoming_emailのemailとpasswordの設定を削除します。ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
Kubernetesシークレットを使用して、受信メールパスワードを格納します。詳細については、Helm IMAPシークレットを参照してください。
最初に
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"コンテナ内に入り、暗号化されたシークレットを編集します:
sudo docker exec -t <container_name> bash gitlab-rake gitlab:incoming_email:secret:edit EDITOR=editor受信メールシークレットの暗号化されていない内容を入力します:
user: 'incoming-email@mail.example.com' password: 'examplepassword'docker-compose.ymlを編集し、incoming_emailのemailとpasswordの設定を削除します。ファイルを保存して、GitLabを再起動します:
docker compose up -d
最初に
/home/git/gitlab/config/gitlab.ymlの受信メール構成が次のようになっている場合:production: incoming_email: user: 'incoming-email@mail.example.com' password: 'examplepassword'暗号化されたシークレットを編集します:
bundle exec rake gitlab:incoming_email:secret:edit EDITOR=vim RAILS_ENVIRONMENT=production受信メールシークレットの暗号化されていない内容を入力します:
user: 'incoming-email@mail.example.com' password: 'examplepassword'/home/git/gitlab/config/gitlab.ymlを編集し、incoming_email:のuserとpasswordの設定を削除します。ファイルを保存して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 mailroomcurl --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のイシューでこの機能を追跡する。