假设我不知道这些信息,有没有使用Java API类查找此信息的方法?请注意,我对Java很陌生 :)
提前致谢,
Andreea
感谢您的答案。 我尝试了以下操作:
public static String getMXRecordsForEmailAddress(String eMailAddress) {
String returnValue = null;
try {
String hostName = getHostNameFromEmailAddress(eMailAddress);
Record[] records = new Lookup(hostName, Type.MX).run();
if (records == null) {
throw new RuntimeException("No MX records found for domain " + hostName + ".");
}
// return first entry (not the best solution)
if (records.length > 0) {
MXRecord mx = (MXRecord) records[0];
returnValue = mx.getTarget().toString();
}
} catch (TextParseException e) {
throw new RuntimeException(e);
}
System.out.println("return value = "+returnValue);
return returnValue;
}
但是,无论hostName的值是什么(例如gmail.com、yahoo.com),Record[] records = new Lookup(hostName, Type.MX).run();总是返回null。
我相信我错过了一些东西,但是我不知道是什么。你能帮我吗?你能告诉我我的错误在哪里吗?
非常感谢,
Andreea
gmail-smtp-in.l.google.com
,但出站SMTP服务器是smtp.gmail.com
。 - David Gelhar