diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index c04f58d57c..1ab9da3407 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3392,8 +3392,17 @@ class Core { !EntityFolder.JUNK.equals(folder.type) && !Arrays.asList(message.keywords).contains(MessageHelper.FLAG_NOT_JUNK)) try { - message.blocklist = DnsBlockList.isJunk( - context, imessage.getHeader("Received")); + message.blocklist = DnsBlockList.isJunk(context, + imessage.getHeader("Received")); + + if (message.blocklist == null || !message.blocklist) { + List
senders = new ArrayList<>(); + if (message.reply != null) + senders.addAll(Arrays.asList(message.reply)); + if (message.from != null) + senders.addAll(Arrays.asList(message.from)); + message.blocklist = DnsBlockList.isJunk(context, senders); + } } catch (Throwable ex) { Log.w(folder.name, ex); } diff --git a/app/src/main/java/eu/faircode/email/DnsBlockList.java b/app/src/main/java/eu/faircode/email/DnsBlockList.java index 4da78e8af0..f06e5cdd79 100644 --- a/app/src/main/java/eu/faircode/email/DnsBlockList.java +++ b/app/src/main/java/eu/faircode/email/DnsBlockList.java @@ -39,6 +39,8 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import javax.mail.Address; +import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeUtility; public class DnsBlockList { @@ -55,7 +57,7 @@ public class DnsBlockList { }), // https://www.spamhaus.org/dbl/ - new BlockList(null, "Spamhaus/DBL", "dbl.spamhaus.org", false, new String[]{ + new BlockList(true, "Spamhaus/DBL", "dbl.spamhaus.org", false, new String[]{ // https://www.spamhaus.org/faq/section/Spamhaus%20DBL#291 "127.0.1.2", // spam domain "127.0.1.4", // phish domain @@ -137,10 +139,28 @@ public class DnsBlockList { return null; String host = getFromHost(MimeUtility.unfold(received[received.length - 1])); - return (host == null ? null : isJunk(context, host, BLOCK_LISTS)); + if (host == null) + return null; + boolean numeric = host.startsWith("[") && host.endsWith("]"); + if (numeric) + host = host.substring(1, host.length() - 1); + + return isJunk(context, host, true, BLOCK_LISTS); } - private static boolean isJunk(Context context, String host, List