|
|
|
@ -2203,6 +2203,38 @@ public class MessageHelper {
|
|
|
|
|
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 {
|
|
|
|
|
ensureHeaders();
|
|
|
|
|
|
|
|
|
@ -2608,38 +2640,6 @@ public class MessageHelper {
|
|
|
|
|
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) {
|
|
|
|
|
if (header.trim().startsWith("=?"))
|
|
|
|
|
return header;
|
|
|
|
|