mirror of https://github.com/M66B/FairEmail.git
Check for native DKIM alignment
This commit is contained in:
parent
c7aa1b8297
commit
9e131fb359
|
@ -3504,22 +3504,10 @@ class Core {
|
||||||
|
|
||||||
if (native_dkim && !BuildConfig.PLAY_STORE_RELEASE) {
|
if (native_dkim && !BuildConfig.PLAY_STORE_RELEASE) {
|
||||||
List<String> signers = helper.verifyDKIM(context);
|
List<String> signers = helper.verifyDKIM(context);
|
||||||
message.signedby = (signers.size() == 0 ? null : TextUtils.join(",", signers));
|
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
|
||||||
if (Boolean.TRUE.equals(message.dkim)) {
|
message.dkim = !signers.isEmpty();
|
||||||
if (signers.size() == 0)
|
message.dmarc = Boolean.TRUE.equals(message.dmarc) ||
|
||||||
message.dkim = false;
|
helper.isAligned(context, signers, message.return_path, message.from);
|
||||||
} else {
|
|
||||||
if (message.from != null)
|
|
||||||
for (Address from : message.from) {
|
|
||||||
String domain = UriHelper.getEmailDomain(((InternetAddress) from).getAddress());
|
|
||||||
if (domain != null && signers.contains(domain)) {
|
|
||||||
message.dkim = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Boolean.TRUE.equals(message.dkim))
|
|
||||||
message.dmarc = message.dkim;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.size == null && message.total != null)
|
if (message.size == null && message.total != null)
|
||||||
|
@ -4668,22 +4656,10 @@ class Core {
|
||||||
|
|
||||||
if (native_dkim && !BuildConfig.PLAY_STORE_RELEASE) {
|
if (native_dkim && !BuildConfig.PLAY_STORE_RELEASE) {
|
||||||
List<String> signers = helper.verifyDKIM(context);
|
List<String> signers = helper.verifyDKIM(context);
|
||||||
message.signedby = (signers.size() == 0 ? null : TextUtils.join(",", signers));
|
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
|
||||||
if (Boolean.TRUE.equals(message.dkim)) {
|
message.dkim = !signers.isEmpty();
|
||||||
if (signers.size() == 0)
|
message.dmarc = Boolean.TRUE.equals(message.dmarc) ||
|
||||||
message.dkim = false;
|
helper.isAligned(context, signers, message.return_path, message.from);
|
||||||
} else {
|
|
||||||
if (message.from != null)
|
|
||||||
for (Address from : message.from) {
|
|
||||||
String domain = UriHelper.getEmailDomain(((InternetAddress) from).getAddress());
|
|
||||||
if (domain != null && signers.contains(domain)) {
|
|
||||||
message.dkim = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Boolean.TRUE.equals(message.dkim))
|
|
||||||
message.dmarc = message.dkim;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borrow reply name from sender name
|
// Borrow reply name from sender name
|
||||||
|
|
|
@ -2610,6 +2610,24 @@ public class MessageHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAligned(Context context, List<String> signers, Address[] return_path, Address[] from) {
|
||||||
|
List<Address> envelop = new ArrayList<>();
|
||||||
|
if (return_path != null)
|
||||||
|
envelop.addAll(Arrays.asList(return_path));
|
||||||
|
if (from != null)
|
||||||
|
envelop.addAll(Arrays.asList(from));
|
||||||
|
for (String signer : signers) {
|
||||||
|
for (Address a : envelop) {
|
||||||
|
String domain = UriHelper.getEmailDomain(((InternetAddress) a).getAddress());
|
||||||
|
if (domain != null && Objects.equals(
|
||||||
|
UriHelper.getRootDomain(context, signer),
|
||||||
|
UriHelper.getRootDomain(context, domain)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Address[] getMailFrom(String[] headers) {
|
Address[] getMailFrom(String[] headers) {
|
||||||
if (headers == null)
|
if (headers == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue