mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 11:25:13 +01:00
Check for no-reply domains
This commit is contained in:
@@ -145,6 +145,13 @@ public class MessageHelper {
|
||||
StandardCharsets.UTF_16LE
|
||||
));
|
||||
|
||||
private static final List<String> DO_NOT_REPLY = Collections.unmodifiableList(Arrays.asList(
|
||||
"noreply",
|
||||
"no.reply",
|
||||
"no-reply",
|
||||
"do-not-reply"
|
||||
));
|
||||
|
||||
static final String FLAG_FORWARDED = "$Forwarded";
|
||||
static final String FLAG_JUNK = "$Junk";
|
||||
static final String FLAG_NOT_JUNK = "$NotJunk";
|
||||
@@ -3216,6 +3223,29 @@ public class MessageHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean isNoReply(Address address) {
|
||||
if (address instanceof InternetAddress) {
|
||||
String email = ((InternetAddress) address).getAddress();
|
||||
String username = UriHelper.getEmailUser(email);
|
||||
String domain = UriHelper.getEmailDomain(email);
|
||||
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
for (String value : DO_NOT_REPLY)
|
||||
if (username.contains(value))
|
||||
return true;
|
||||
}
|
||||
if (!TextUtils.isEmpty(domain)) {
|
||||
domain = domain.toLowerCase(Locale.ROOT);
|
||||
for (String value : DO_NOT_REPLY)
|
||||
if (domain.startsWith(value))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean equalEmail(Address a1, Address a2) {
|
||||
String email1 = ((InternetAddress) a1).getAddress();
|
||||
String email2 = ((InternetAddress) a2).getAddress();
|
||||
|
||||
Reference in New Issue
Block a user