keycloak - greenmail - keycloak connection doesn't work
问题描述
I'm trying to write some integration tests on my keycload flows. To validate the registration and password forgotten mails, I would like to use greenmail.
my docker configuration of greenmail (within docker compose):
greenmail:
image: greenmail/standalone:1.5.7
environment:
- GREENMAIL_OPTS=-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose
ports:
- "3025:3025"
- "3143:3143"
when I click on "test connection", it doesn't work and I get in my logs: error message (for those who can't open/display the image):
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 3025; timeout 1000;
nester exception is: Connection refused
someone knows what I'm missing?
解决方案
问题不是 greenmail 或 keycloak,而是在 keycloak 配置中使用的 docker => localhost 是 keycloak docker 容器的 localhost 映射,而不是 docker 主机(即运行它的系统)的映射。将 keycloak 的 smtp 主机更改为 'host.docker.internal' 解决了问题 => 这是在 docker 容器中获取主机 IP 地址的方法
推荐阅读
- python - 如何将列表视图移动到 MDToolbar 下方
- sql - 将非常大的文本文件导入 sql。速度问题
- reactjs - 无法使用 MobX 和 React js 在页面加载中加载数据
- python - 张量流模型的多个输入(数据集列表)
- python - 循环时出现错误“列表索引必须是整数或切片,而不是 str”
- javascript - NextJS styled-components 在捆绑文件中给出错误
- python-3.x - Selenium ActionChains 对 Mac 没有影响
- html - HTML CSS 添加下拉菜单
- html - CSS DIV 伸出另一个 DIV
- matlab - 在 MATLAB 中对坐标网格执行线性变换