mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
c9fbc5707e
commit
420d78efeb
|
@ -2203,6 +2203,38 @@ public class MessageHelper {
|
||||||
return false; // fail, policy, neutral, temperror, permerror
|
return false; // fail, policy, neutral, temperror, permerror
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Address[] getMailFrom(String[] headers) {
|
||||||
|
if (headers == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Address[] mailfrom = null;
|
||||||
|
for (String header : headers) {
|
||||||
|
String spf = getKeyValues(header).get("spf");
|
||||||
|
if (spf == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int i = spf.indexOf(SMTP_MAILFORM + "=");
|
||||||
|
if (i < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String v = spf.substring(i + SMTP_MAILFORM.length() + 1);
|
||||||
|
int s = v.indexOf(' ');
|
||||||
|
if (s > 0)
|
||||||
|
v = v.substring(0, s);
|
||||||
|
|
||||||
|
if (v.startsWith("\"") && v.endsWith("\""))
|
||||||
|
v = v.substring(1, v.length() - 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mailfrom = InternetAddress.parseHeader(v, false);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mailfrom;
|
||||||
|
}
|
||||||
|
|
||||||
boolean getSPF() throws MessagingException {
|
boolean getSPF() throws MessagingException {
|
||||||
ensureHeaders();
|
ensureHeaders();
|
||||||
|
|
||||||
|
@ -2608,38 +2640,6 @@ public class MessageHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Address[] getMailFrom(String[] headers) {
|
|
||||||
if (headers == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Address[] mailfrom = null;
|
|
||||||
for (String header : headers) {
|
|
||||||
String spf = getKeyValues(header).get("spf");
|
|
||||||
if (spf == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int i = spf.indexOf(SMTP_MAILFORM + "=");
|
|
||||||
if (i < 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String v = spf.substring(i + SMTP_MAILFORM.length() + 1);
|
|
||||||
int s = v.indexOf(' ');
|
|
||||||
if (s > 0)
|
|
||||||
v = v.substring(0, s);
|
|
||||||
|
|
||||||
if (v.startsWith("\"") && v.endsWith("\""))
|
|
||||||
v = v.substring(1, v.length() - 1);
|
|
||||||
|
|
||||||
try {
|
|
||||||
mailfrom = InternetAddress.parseHeader(v, false);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mailfrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String fixEncoding(String name, String header) {
|
private String fixEncoding(String name, String header) {
|
||||||
if (header.trim().startsWith("=?"))
|
if (header.trim().startsWith("=?"))
|
||||||
return header;
|
return header;
|
||||||
|
|
Loading…
Reference in New Issue