Email providers
An email provider sends the emails of Casdoor, such as verification codes at sign-up and sign-in, password reset links, and notifications. This page describes the settings of an SMTP provider and the email templates. Other pages of this section cover specific services.
Add an SMTP provider
-
In the Casdoor admin console, go to Identity > Providers and add a provider.
-
Set Category to
Emailand Type toDefault, which sends through SMTP. -
Enter the Host, Port, Username, and Password of your SMTP server, and the From address.

-
Write the Email title and the Email content. See Templates.

-
Click Test SMTP Connection to check the connection, and Send Testing Email to send a message to the Test Email address.
-
Save the provider and add it to your application. See Add providers to an application.
Other email types
| 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 | The SMTP server of Exchange Online, signing in with OAuth instead of a password. See Microsoft 365 |
Microsoft Graph | The sendMail API of Microsoft Graph, for tenants where SMTP AUTH is off. See Microsoft Graph |
Gmail | The SMTP server of Gmail, signing in with a Google JSON key instead of an app password. See Gmail |
Custom HTTP Email | An HTTP API that you describe. See Send email through your own HTTP API |
SSL mode
SSL mode controls how Casdoor negotiates TLS with the SMTP server:
| Value | Behavior |
|---|---|
Auto (default) | Decides by the port: implicit TLS on port 465, STARTTLS on other ports |
Enable | Always uses implicit TLS. Use it when the server requires implicit TLS on a non-standard port |
Disable | Doesn't use TLS. Use it only for servers on a trusted internal network |
Providers that had the former Disable SSL option turned on behave as Disable. You don't migrate them by hand.
Proxy
If Casdoor can't reach the SMTP server directly, for example Gmail from a restricted network, turn on Enable proxy. Casdoor then sends email through the SOCKS5 proxy that socks5Proxy in conf/app.conf sets. For SMTP, write socks5Proxy as host:port: the SMTP connection doesn't accept the socks5:// prefix or a username and password in the value.
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.
Templates
Email title and Email content can contain the following placeholders:
| Placeholder | 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 | The lifetime of the magic link in minutes. Replaced only in magic-link emails |
Password reset link
To let users reset their password with a link in the email, put the link text and %link in a <reset-link> block. Casdoor shows the block only in password reset emails and removes it from all other emails, such as sign-up and sign-in codes.
Casdoor fills in %link only if it knows its own public URL: origin or originFrontend is set in conf/app.conf, or the request reaches Casdoor on a loopback host such as localhost. Otherwise, it removes the <reset-link> block from password reset emails too, and the email contains only the code. Casdoor doesn't build the link from the Host header of the request, because anyone can set that header. The same rule applies to magic links, which fail with please set "origin" in conf/app.conf to send magic links. See the Configuration reference.
A magic-link email uses the same Email content. If the content has no %link, Casdoor sends a built-in body with the link instead.
Codes and magic links are valid for verificationCodeTimeout minutes, set in conf/app.conf. The default is 10. The examples below say 10 minutes, so change the text if you change the setting.
Plain text:
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>
