KeyCloak 无法使用 SMTP 发送电子邮件,状态为 500

问题描述 投票:0回答:2

我在 Kubernetes 集群中运行了 Keycloak。身份验证有效,但我需要设置电子邮件才能发送电子邮件进行验证和密码重置。

我已将 SendGrid 设置为 SMTP 中继。当我使用 SendGrid java 客户端 发送邮件时,这些设置(主机、端口和 api 密钥)起作用。然而,当在 KeyCloak 中按

Test connection
时,我得到:

[Error] Failed to load resource: the server responded with a status of 500 () 
[Debug] Remove message (services.js, line 14)
[Debug] Added message (services.js, line 15)
[Error] Can't find variable: error
https://<domain>/auth/resources/ong8v/admin/keycloak/js/controllers/realm.js:76 – "Possibly unhandled rejection: {}"
[Debug] Remove message (services.js, line 14)

这里没什么可说的。我为当前登录的用户设置了一个电子邮件地址。我还尝试过重置密码,以防

Test connection
功能损坏,但这也不起作用。

电子邮件的

Realm Settings
设置用户如下:

host: smtp.sendgrid.net
port: 587
from: test@<domain>
Enable StartTLS: true
Username: "apikey"
Password: <api key>

知道可能出了什么问题吗?或者如何查明?例如,也许我可以以某种方式获得更有意义的错误消息。


编辑:

我得到了服务器日志。

Failed to send email: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.sendgrid.net, 587; timeout 10000;
nested exception is: java.net.SocketTimeoutException: connect timed out

编辑2:

我尝试使用完全相同的设置使用 Telnet 发送邮件,并且有效。因此,显然是 Keycloak 或其底层 Java 库导致了发送电子邮件的问题。

email smtp keycloak sendgrid
2个回答
1
投票

事实证明 Keycloak 有效,并且电子邮件被托管提供商阻止。


0
投票

此外,如果您使用 bitnami helm 图表部署了 keycloak,那么您可能会偶然发现 500 错误

networkPolicy:
  allowExternalEgress: false

为了修复它,让它

true

networkPolicy:
  allowExternalEgress: true
© www.soinside.com 2019 - 2024. All rights reserved.