mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32: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
154206c5f3
commit
b62e2f3e8e
@ -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");
|
||||
|
||||
@ -31,6 +31,7 @@ import java.util.Locale;
|
||||
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
@ -168,6 +169,8 @@ public class EmailTest extends AbstractI18NTest {
|
||||
|
||||
MimeMessage message = greenMail.getReceivedMessages()[expectedMsgCount - 1];
|
||||
|
||||
assertThat(message.getMessageID(), Matchers.endsWith("@keycloak.org>"));
|
||||
|
||||
assertEquals(expectedSubject, message.getSubject());
|
||||
|
||||
String textBody = MailUtils.getBody(message).getText();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user