メールプロバイダー
メールプロバイダーは、Casdoor のメール(サインアップやサインイン時の認証コード、パスワードリセットリンク、通知など)を送信します。このページでは、SMTP プロバイダーの設定とメールテンプレートについて説明します。このセクションの他のページでは、具体的なサービスを取り扱います。
SMTP プロバイダーを追加する
-
Casdoor 管理コンソールで Identity > Providers に移動し、プロバイダーを追加します。
-
Category を
Emailに、Type をDefault(SMTP 経由で送信)に設定します。 -
SMTP サーバーの Host、Port、Username、Password、および From address を入力します。

-
Email title と Email content を記述します。Templates を参照してください。

-
Test SMTP Connection をクリックして接続を確認し、Send Testing Email をクリックして Test Email アドレスにメッセージを送信します。
-
プロバイダーを保存し、アプリケーションに追加します。Add providers to an application を参照してください。
その他のメールタイプ
| Type | Sends through |
|---|---|
Default | An SMTP server, as described on this page |
SUBMAIL, Mailtrap | The SMTP server of the service, with the same fields as Default |
Azure ACS | Azure Communication Services. See Azure ACS |
SendGrid | SendGrid. See SendGrid |
Resend | Resend. See Resend |
Microsoft 365 | Exchange Online の SMTP サーバー。パスワードではなく OAuth を使用してサインインします。Microsoft 365 を参照してください |
Microsoft Graph | Microsoft Graph の sendMail API。SMTP AUTH がオフになっているテナント向けです。Microsoft Graph を参照してください |
Gmail | Gmail の SMTP サーバー。アプリパスワードではなく Google JSON キーでサインインします。Gmail を参照してください |
Custom HTTP Email | An HTTP API that you describe. See Send email through your own HTTP API |
SSLモード
SSL mode は、Casdoor が SMTP サーバーと TLS をどのようにネゴシエートするかを制御します:
| 値 | Behavior |
|---|---|
Auto (default) | Decides by the port: implicit TLS on port 465, STARTTLS on other ports |
有効 | Always uses implicit TLS. Use it when the server requires implicit TLS on a non-standard port |
無効 | Doesn't use TLS. Use it only for servers on a trusted internal network |
以前は Disable SSL オプションがオンになっていたプロバイダーは、Disable として動作します。手動での移行は不要です。
プロキシ
制限されたネットワークからの Gmail など、Casdoor が SMTP サーバーに直接到達できない場合は、Enable proxy をオンにします。その後、Casdoor は conf/app.conf の socks5Proxy で設定された SOCKS5 プロキシを通じてメールを送信します。SMTP の場合、socks5Proxy は host:port の形式で記述します。SMTP 接続では、値に socks5:// プレフィックスやユーザー名・パスワードを受け付けません。
An email provider that belongs to an organization other than admin, built-in, and the trusted organizations can send only to SMTP servers and HTTP endpoints at Internet addresses. See Which addresses a provider can reach.
テンプレート
Email title と Email content には、以下のプレースホルダーを含めることができます:
| プレースホルダー | Replaced by |
|---|---|
%{user.friendlyName} | The display name or another friendly name of the user |
%s | The verification code |
%link | The password reset URL. Use it only inside a <reset-link> block. In a magic-link email, the sign-in link |
%expireTime | マジックリンクの有効期間(分)。マジックリンクメールでのみ置換されます |
パスワードリセットリンク
ユーザーがメール内のリンクでパスワードをリセットできるようにするには、リンクテキストと %link を <reset-link> ブロック内に配置します。Casdoor はこのブロックをパスワードリセットメールでのみ表示し、サインアップやサインインコードなどの他のすべてのメールからは削除します。
Casdoor が %link を埋め込むのは、自身の公開 URL を認識している場合のみです。つまり、conf/app.conf で origin または originFrontend が設定されているか、リクエストが localhost などのループバックホスト経由で Casdoor に到達する場合です。それ以外の場合、Casdoor はパスワードリセットメールからも <reset-link> ブロックを削除し、メールにはコードのみが含まれます。リクエストの Host ヘッダーは誰でも設定できるため、Casdoor はそこからリンクを構築しません。同じルールがマジックリンクにも適用され、失敗時には please set "origin" in conf/app.conf to send magic links というエラーが表示されます。Configuration reference を参照してください。
マジックリンクメールは同じ Email content を使用します。コンテンツに %link がない場合、Casdoor は代わりにリンクを含む組み込み本文を送信します。
コードとマジックリンクは conf/app.conf で設定される verificationCodeTimeout 分間有効です。デフォルトは 10 です。以下の例では 10 分と記載されているため、設定を変更した場合はテキストも変更してください。
プレーンテキスト:
You have requested a verification code at Casdoor. Here is your code: %s, please enter in 10 minutes. <reset-link>Or click %link to reset</reset-link>
HTML:
<!DOCTYPE html>
<html>
<body>
<h2>Password Reset Request</h2>
<p>Hello %{'{'}user.friendlyName{'}'},</p>
<p>Your verification code is: <strong>%s</strong></p>
<p>This code will expire in 10 minutes.</p>
<reset-link>
<p>Alternatively, you can <a href="%link">click here to reset your password</a> directly.</p>
</reset-link>
<p>If you didn't request this, please ignore this email.</p>
</body>
</html>
