Evuluate Received-SPF

pull/215/head
M66B 8 months ago
parent 7f4c0f6efb
commit ade60c608b

@ -3454,8 +3454,8 @@ class Core {
message.tls = helper.getTLS();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
if (message.spf == null && helper.getSPF())
message.spf = true;
if (message.spf == null)
message.spf = helper.getSPF();
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.auth = MessageHelper.getAuthentication("auth", authentication);
message.smtp_from = helper.getMailFrom(authentication);
@ -4634,8 +4634,8 @@ class Core {
message.tls = helper.getTLS();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
if (message.spf == null && helper.getSPF())
message.spf = true;
if (message.spf == null)
message.spf = helper.getSPF();
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.auth = MessageHelper.getAuthentication("auth", authentication);
message.smtp_from = helper.getMailFrom(authentication);

@ -1557,8 +1557,8 @@ public class FragmentFolders extends FragmentBase {
message.tls = helper.getTLS();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
if (message.spf == null && helper.getSPF())
message.spf = true;
if (message.spf == null)
message.spf = helper.getSPF();
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.auth = MessageHelper.getAuthentication("auth", authentication);
message.smtp_from = helper.getMailFrom(authentication);

@ -2272,16 +2272,32 @@ public class MessageHelper {
return signer;
}
boolean getSPF() throws MessagingException {
Boolean getSPF() throws MessagingException {
ensureHeaders();
// http://www.open-spf.org/RFC_4408/#header-field
String[] headers = imessage.getHeader("Received-SPF");
if (headers == null || headers.length < 1)
return false;
return null;
// header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] [ key-value-list ] CRLF
// result = "Pass" / "Fail" / "SoftFail" / "Neutral" / "None" / "TempError" / "PermError"
String spf = MimeUtility.unfold(headers[0]);
return (spf.trim().toLowerCase(Locale.ROOT).startsWith("pass"));
String[] values = spf.trim().split("\\s+");
if (values.length == 0)
return null;
String value = values[0].toLowerCase(Locale.ROOT);
switch (value) {
case "pass":
return true;
case "neutral":
case "none":
return null;
default:
return false;
}
}
@NonNull

Loading…
Cancel
Save