This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 133740a99a JAMES-4144 RecipientHasMXRecord + SenderHasMXRecord (#2804)
133740a99a is described below

commit 133740a99a738c36ea618d495415a0916716aaef
Author: Benoit TELLIER <[email protected]>
AuthorDate: Tue Sep 16 10:48:30 2025 +0200

    JAMES-4144 RecipientHasMXRecord + SenderHasMXRecord (#2804)
---
 .../servers/partials/RecipientHasMXRecord.adoc     |  14 ++
 .../servers/partials/SenderHasMXRecord.adoc        |  14 ++
 .../servers/partials/configure/matchers.adoc       |   4 +
 .../transport/matchers/RecipientHasMXRecord.java   |  88 ++++++++++
 .../transport/matchers/SenderHasMXRecord.java      |  88 ++++++++++
 .../matchers/RecipientHasMXRecordTest.java         | 189 +++++++++++++++++++++
 .../transport/matchers/SenderHasMXRecordTest.java  | 166 ++++++++++++++++++
 7 files changed, 563 insertions(+)

diff --git a/docs/modules/servers/partials/RecipientHasMXRecord.adoc 
b/docs/modules/servers/partials/RecipientHasMXRecord.adoc
new file mode 100644
index 0000000000..2e323cf901
--- /dev/null
+++ b/docs/modules/servers/partials/RecipientHasMXRecord.adoc
@@ -0,0 +1,14 @@
+=== RecipientHasMXRecord
+
+Enable to validate that the recipients of the email address domain name has a 
MX record advertised through DNS
+that matches a supplied list of domains.
+
+This is for instance useful when registering dynamically a public email 
service and ensure correct configuration
+of the domain upon receival and mitigate some identity spoofing attempts on a 
publicly accessible platform allowing
+dynamic domain registration.
+
+Example:
+
+....
+<mailet match="RecipientHasMXRecord=mx.apache.org" class="any-class"/>
+....
\ No newline at end of file
diff --git a/docs/modules/servers/partials/SenderHasMXRecord.adoc 
b/docs/modules/servers/partials/SenderHasMXRecord.adoc
new file mode 100644
index 0000000000..a50cc44d58
--- /dev/null
+++ b/docs/modules/servers/partials/SenderHasMXRecord.adoc
@@ -0,0 +1,14 @@
+=== SenderHasMXRecord
+
+Enable to validate that the sender of the email address domain name has a MX 
record advertised through DNS
+that matches a supplied list of domains.
+
+This is for instance useful when registering dynamically a public email 
service and ensure correct configuration
+of the domain upon sending and mitigate some identity spoofing attempts on a 
publicly accessible platform allowing
+dynamic domain registration.
+
+Example:
+
+....
+<mailet match="SenderHasMXRecord=mx.apache.org" class="any-class"/>
+....
\ No newline at end of file
diff --git a/docs/modules/servers/partials/configure/matchers.adoc 
b/docs/modules/servers/partials/configure/matchers.adoc
index 83b781c2f9..eb8048154a 100644
--- a/docs/modules/servers/partials/configure/matchers.adoc
+++ b/docs/modules/servers/partials/configure/matchers.adoc
@@ -63,6 +63,8 @@ include::partial$RecipientCountExceeds.adoc[]
 
 include::partial$RecipientDomainIs.adoc[]
 
+include::partial$RecipientHasMXRecord.adoc[]
+
 include::partial$RecipientIs.adoc[]
 
 include::partial$RecipientIsLocal.adoc[]
@@ -81,6 +83,8 @@ include::partial$SenderDomainIs.adoc[]
 
 include::partial$SenderHostIs.adoc[]
 
+include::partial$SenderHasMXRecord.adoc[]
+
 include::partial$SenderIs.adoc[]
 
 include::partial$SenderIsLocal.adoc[]
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RecipientHasMXRecord.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RecipientHasMXRecord.java
new file mode 100644
index 0000000000..48ba944526
--- /dev/null
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RecipientHasMXRecord.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.transport.matchers;
+
+import java.util.Collection;
+
+import jakarta.inject.Inject;
+import jakarta.mail.MessagingException;
+
+import org.apache.james.core.Domain;
+import org.apache.james.core.MailAddress;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.TemporaryResolutionException;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMatcher;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Enable to validate that the recipients of the email address domain name has 
a MX record advertised through DNS
+ * that matches a supplied list of domains.
+ *
+ * This is for instance useful when registering dynamically a public email 
service and ensure correct configuration
+ * of the domain upon receival and mitigate some identity spoofing attempts on 
a publicly accessible platform allowing
+ * dynamic domain registration.
+ *
+ * Example:
+ *
+ *  &lt;mailet match=&quot;RecipientHasMXRecord=mx.apache.org&quot; 
class=&quot;&lt;any-class&gt;&quot;/&gt;
+ */
+public class RecipientHasMXRecord extends GenericMatcher {
+    private final DNSService dnsService;
+    private ImmutableList<String> expectedMxRecords;
+
+    @Inject
+    public RecipientHasMXRecord(DNSService dnsService) {
+        this.dnsService = dnsService;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        expectedMxRecords = Splitter.on(',')
+            .splitToStream(getCondition())
+            .map(Domain::of)
+            .map(Domain::asString)
+            .sorted()
+            .collect(ImmutableList.toImmutableList());
+    }
+
+    @Override
+    public Collection<MailAddress> match(Mail mail) throws MessagingException {
+        return mail.getRecipients()
+            .stream()
+            .filter(this::matchesExpectedMxRecord)
+            .collect(ImmutableList.toImmutableList());
+    }
+
+    private boolean matchesExpectedMxRecord(MailAddress address) {
+        try {
+            ImmutableList<String> mxRecords = 
dnsService.findMXRecords(address.getDomain().asString())
+                .stream()
+                .sorted()
+                .collect(ImmutableList.toImmutableList());
+
+            return expectedMxRecords.equals(mxRecords);
+        } catch (TemporaryResolutionException e) {
+            return false;
+        }
+    }
+}
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderHasMXRecord.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderHasMXRecord.java
new file mode 100644
index 0000000000..35985af0d3
--- /dev/null
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderHasMXRecord.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.transport.matchers;
+
+import java.util.Collection;
+
+import jakarta.inject.Inject;
+import jakarta.mail.MessagingException;
+
+import org.apache.james.core.Domain;
+import org.apache.james.core.MailAddress;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.TemporaryResolutionException;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMatcher;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Enable to validate that the sender of the email address domain name has a 
MX record advertised through DNS
+ * that matches a supplied list of domains.
+ *
+ * This is for instance useful when registering dynamically a public email 
service and ensure correct configuration
+ * of the domain upon sending and mitigate some identity spoofing attempts on 
a publicly accessible platform allowing
+ * dynamic domain registration.
+ *
+ * Example:
+ *
+ *  &lt;mailet match=&quot;SenderHasMXRecord=mx.apache.org&quot; 
class=&quot;&lt;any-class&gt;&quot;/&gt;
+ */
+public class SenderHasMXRecord extends GenericMatcher {
+    private final DNSService dnsService;
+    private ImmutableList<String> expectedMxRecords;
+
+    @Inject
+    public SenderHasMXRecord(DNSService dnsService) {
+        this.dnsService = dnsService;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        expectedMxRecords = Splitter.on(',')
+            .splitToStream(getCondition())
+            .map(Domain::of)
+            .map(Domain::asString)
+            .sorted()
+            .collect(ImmutableList.toImmutableList());
+    }
+
+    @Override
+    public Collection<MailAddress> match(Mail mail) throws MessagingException {
+        return mail.getMaybeSender().asOptional()
+            .filter(this::matchesExpectedMxRecord)
+            .map(any -> mail.getRecipients())
+            .orElse(ImmutableList.of());
+    }
+
+    private boolean matchesExpectedMxRecord(MailAddress address) {
+        try {
+            ImmutableList<String> mxRecords = 
dnsService.findMXRecords(address.getDomain().asString())
+                .stream()
+                .sorted()
+                .collect(ImmutableList.toImmutableList());
+
+            return expectedMxRecords.equals(mxRecords);
+        } catch (TemporaryResolutionException e) {
+            return false;
+        }
+    }
+}
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RecipientHasMXRecordTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RecipientHasMXRecordTest.java
new file mode 100644
index 0000000000..5444e0475f
--- /dev/null
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RecipientHasMXRecordTest.java
@@ -0,0 +1,189 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.matchers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Collection;
+
+import org.apache.james.core.MailAddress;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.TemporaryResolutionException;
+import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.FakeMatcherConfig;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.google.common.collect.ImmutableList;
+
+class RecipientHasMXRecordTest {
+
+    private DNSService dnsService;
+    private RecipientHasMXRecord testee;
+
+    @BeforeEach
+    void setUp() {
+        dnsService = mock(DNSService.class);
+        testee = new RecipientHasMXRecord(dnsService);
+    }
+
+    @Test
+    void initShouldRejectEmptyConfig() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void initShouldRejectEmptyDomain() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("domain.tld,,other.tld")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void initShouldRejectInvalidDomain() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("invalid@com")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenNoDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+        when(dnsService.findMXRecords(anyString())).thenThrow(new 
TemporaryResolutionException());
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenWrongDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.unrelated.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenUnrelatedDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.domain.com", "mx.unrelated.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnMailRecipientsWhenCorrectMX() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.domain.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isNotEmpty();
+    }
+
+    @Test
+    void matchShouldSupportMultipleMXRecords() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx1.domain.com,mx2.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx1.domain.com", "mx2.domain.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isNotEmpty();
+    }
+
+    @Test
+    void matchShouldFilterRecipients() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("RecipientHasMXRecord")
+            .condition("mx1.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(eq("domain1.com")))
+            .thenReturn(ImmutableList.of("mx1.domain.com"));
+        when(dnsService.findMXRecords(eq("domain2.com")))
+            .thenReturn(ImmutableList.of("mx2.domain.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).containsOnly(new 
MailAddress("[email protected]"));
+    }
+}
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/SenderHasMXRecordTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/SenderHasMXRecordTest.java
new file mode 100644
index 0000000000..3cd8256ff7
--- /dev/null
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/SenderHasMXRecordTest.java
@@ -0,0 +1,166 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.matchers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Collection;
+
+import org.apache.james.core.MailAddress;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.TemporaryResolutionException;
+import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.FakeMatcherConfig;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.google.common.collect.ImmutableList;
+
+class SenderHasMXRecordTest {
+
+    private DNSService dnsService;
+    private SenderHasMXRecord testee;
+
+    @BeforeEach
+    void setUp() {
+        dnsService = mock(DNSService.class);
+        testee = new SenderHasMXRecord(dnsService);
+    }
+
+    @Test
+    void initShouldRejectEmptyConfig() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void initShouldRejectEmptyDomain() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("domain.tld,,other.tld")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void initShouldRejectInvalidDomain() {
+        assertThatThrownBy(() -> testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("invalid@com")
+            .build())).isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenNoDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+        when(dnsService.findMXRecords(anyString())).thenThrow(new 
TemporaryResolutionException());
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenWrongDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.unrelated.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnEmptyWhenUnrelatedDnsEntry() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.domain.com", "mx.unrelated.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    void matchShouldReturnMailRecipientsWhenCorrectMX() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("mx.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx.domain.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isNotEmpty();
+    }
+
+    @Test
+    void matchShouldSupportMultipleMXRecords() throws Exception {
+        testee.init(FakeMatcherConfig.builder()
+            .matcherName("SenderHasMXRecord")
+            .condition("mx1.domain.com,mx2.domain.com")
+            .build());
+
+        when(dnsService.findMXRecords(anyString()))
+            .thenReturn(ImmutableList.of("mx1.domain.com", "mx2.domain.com"));
+
+        Collection<MailAddress> result = testee.match(FakeMail.builder()
+            .name("anything")
+            .sender("[email protected]")
+            .recipient("[email protected]")
+            .build());
+
+        assertThat(result).isNotEmpty();
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to