mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 15:02:05 -03:30
Set the mail.from to avoid looking up the local hostname
Closes #38353 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
parent
65540d8eb2
commit
73a20cbf89
@ -115,6 +115,11 @@ public class DefaultEmailSenderProvider implements EmailSenderProvider {
|
||||
throw new EmailException("No sender address configured in the realm settings for emails");
|
||||
}
|
||||
|
||||
// Specify 'mail.from' as InternetAddress.getLocalAddress() would otherwise do a InetAddress.getCanonicalHostName
|
||||
// and add this as a mail header. This would both be slow, and would reveal internal IP addresses that we don't want.
|
||||
// https://jakarta.ee/specifications/mail/2.0/jakarta-mail-spec-2.0#a823
|
||||
props.setProperty("mail.from", from);
|
||||
|
||||
String fromDisplayName = config.get("fromDisplayName");
|
||||
String replyTo = config.get("replyTo");
|
||||
String replyToDisplayName = config.get("replyToDisplayName");
|
||||
|
||||
@ -3,6 +3,8 @@ package org.keycloak.test.examples;
|
||||
import com.nimbusds.oauth2.sdk.GeneralException;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.keycloak.events.email.EmailEventListenerProviderFactory;
|
||||
@ -50,6 +52,7 @@ public class EmailTest {
|
||||
mail.waitForIncomingEmail(1);
|
||||
MimeMessage lastReceivedMessage = mail.getLastReceivedMessage();
|
||||
Assertions.assertEquals("Login error", lastReceivedMessage.getSubject());
|
||||
MatcherAssert.assertThat(lastReceivedMessage.getMessageID(), Matchers.endsWith("@keycloak.org>"));
|
||||
}
|
||||
|
||||
public static class EmailSenderRealmConfig implements RealmConfig {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user