我正在尝试在我的keycload流上编写一些集成测试。 为了验证注册和忘记密码的邮件,我想使用greenmail。
我的greenmail docker配置(在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"
当我单击“测试连接”时,它不起作用并且进入日志: 错误消息(对于那些无法打开/显示图像的人):
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 3025; timeout 1000;
nester exception is: Connection refused
有人知道我想念什么吗?
答案 0 :(得分:0)
问题不是greenmail或密钥斗篷,而是docker =>在keycloak配置中使用的localhost是keycloak docker容器而不是docker主机(即运行它的系统)的localhost映射。 将keycloak的smtp主机更改为'host.docker.internal'解决了问题=>这是在Docker容器中获取主机ip地址的方法