本文整理了Java中org.apache.mailet.Mail.getRemoteAddr()
方法的一些代码示例,展示了Mail.getRemoteAddr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mail.getRemoteAddr()
方法的具体详情如下:
包路径:org.apache.mailet.Mail
类名称:Mail
方法名:getRemoteAddr
[英]Returns the IP address of the remote server that sent this message.
[中]返回发送此消息的远程服务器的IP地址。
代码示例来源:origin: org.apache.james/james-server-mailets
@Override
public Collection<MailAddress> match(Mail mail) {
String host = mail.getRemoteAddr();
try {
// Have to reverse the octets first
StringBuilder sb = new StringBuilder();
StringTokenizer st = new StringTokenizer(host, " .", false);
while (st.hasMoreTokens()) {
sb.insert(0, st.nextToken() + ".");
}
// Add the network prefix for this blacklist
sb.append(network);
// Try to look it up
dnsServer.getByName(sb.toString());
// If we got here, that's bad... it means the host
// was found in the blacklist
return mail.getRecipients();
} catch (UnknownHostException uhe) {
// This is good... it's not on the list
return null;
}
}
}
代码示例来源:origin: org.apache.james/james-server-mailets
@Override
public Collection<MailAddress> match(Mail mail) {
if (! matchNetwork(mail.getRemoteAddr())) {
return mail.getRecipients();
}
return null;
}
}
代码示例来源:origin: org.apache.james/james-server-mailets
@Override
public Collection<MailAddress> match(Mail mail) {
if (matchNetwork(mail.getRemoteAddr())) {
return mail.getRecipients();
}
return null;
}
}
代码示例来源:origin: org.apache.james/james-server-queue-jms
protected Map<String, Object> getJMSProperties(Mail mail, long nextDelivery) throws MessagingException {
Map<String, Object> props = new HashMap<>();
props.put(JAMES_NEXT_DELIVERY, nextDelivery);
props.put(JAMES_MAIL_ERROR_MESSAGE, mail.getErrorMessage());
props.put(JAMES_MAIL_LAST_UPDATED, mail.getLastUpdated().getTime());
props.put(JAMES_MAIL_MESSAGE_SIZE, mail.getMessageSize());
props.put(JAMES_MAIL_NAME, mail.getName());
// won't serialize the empty headers so it is mandatory
// to handle nulls when reconstructing mail from message
if (!mail.getPerRecipientSpecificHeaders().getHeadersByRecipient().isEmpty()) {
props.put(JAMES_MAIL_PER_RECIPIENT_HEADERS, SerializationUtil.serialize(mail.getPerRecipientSpecificHeaders()));
}
String recipientsAsString = joiner.join(mail.getRecipients());
props.put(JAMES_MAIL_RECIPIENTS, recipientsAsString);
props.put(JAMES_MAIL_REMOTEADDR, mail.getRemoteAddr());
props.put(JAMES_MAIL_REMOTEHOST, mail.getRemoteHost());
String sender = mail.getMaybeSender().asString("");
org.apache.james.util.streams.Iterators.toStream(mail.getAttributeNames())
.forEach(attrName -> props.put(attrName, SerializationUtil.serialize(mail.getAttribute(attrName))));
props.put(JAMES_MAIL_ATTRIBUTE_NAMES, joiner.join(mail.getAttributeNames()));
props.put(JAMES_MAIL_SENDER, sender);
props.put(JAMES_MAIL_STATE, mail.getState());
return props;
}
代码示例来源:origin: org.apache.james/james-server-mailets
boolean matched = matcher.matchInetNetwork(mail.getRemoteAddr());
matched = matcher.matchInetNetwork(mail.getRemoteAddr());
代码示例来源:origin: org.apache.james/james-server-queue-jms
map.put(names[4], m.getMessageSize());
map.put(names[5], m.getLastUpdated().getTime());
map.put(names[6], m.getRemoteAddr());
map.put(names[7], m.getRemoteHost());
map.put(names[8], m.getErrorMessage());
代码示例来源:origin: org.apache.james/james-server-webadmin-mailrepository
public static MailDto fromMail(Mail mail, Set<AdditionalField> additionalFields) throws MessagingException, InaccessibleFieldException {
Optional<MessageContent> messageContent = fetchMessage(additionalFields, mail);
return new MailDto(mail.getName(),
mail.getMaybeSender().asOptional().map(MailAddress::asString),
mail.getRecipients().stream().map(MailAddress::asString).collect(Guavate.toImmutableList()),
Optional.ofNullable(mail.getErrorMessage()),
Optional.ofNullable(mail.getState()),
Optional.ofNullable(mail.getRemoteHost()),
Optional.ofNullable(mail.getRemoteAddr()),
Optional.ofNullable(mail.getLastUpdated()),
fetchAttributes(additionalFields, mail),
fetchPerRecipientsHeaders(additionalFields, mail),
fetchHeaders(additionalFields, mail),
fetchTextBody(additionalFields, messageContent),
fetchHtmlBody(additionalFields, messageContent),
fetchMessageSize(additionalFields, mail));
}
代码示例来源:origin: org.apache.james/james-server-core-library
/**
* @param mail
* @param newName
* @throws MessagingException
*/
public MailImpl(Mail mail, String newName) throws MessagingException {
this(newName, mail.getSender(), mail.getRecipients(), mail.getMessage());
setRemoteHost(mail.getRemoteHost());
setRemoteAddr(mail.getRemoteAddr());
setLastUpdated(mail.getLastUpdated());
try {
if (mail instanceof MailImpl) {
setAttributesRaw((HashMap) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
} else {
HashMap attribs = new HashMap();
for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
String hashKey = (String) i.next();
attribs.put(hashKey,cloneSerializableObject(mail.getAttribute(hashKey)));
}
setAttributesRaw(attribs);
}
} catch (IOException e) {
// should never happen for in memory streams
setAttributesRaw(new HashMap());
} catch (ClassNotFoundException e) {
// should never happen as we just serialized it
setAttributesRaw(new HashMap());
}
}
代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel
.addContext(MDCBuilder.PROTOCOL, "MAILET")
.addContext(MDCBuilder.ACTION, "MATCHER")
.addContext(MDCBuilder.IP, mail.getRemoteAddr())
.addContext(MDCBuilder.HOST, mail.getRemoteHost())
.addContext("matcher", matcher.getMatcherInfo())
代码示例来源:origin: org.apache.james/james-server-mailets
@Override
public void service(Mail mail) throws MessagingException {
String remoteAddr = mail.getRemoteAddr();
String helo = mail.getRemoteHost();
if (!remoteAddr.equals("127.0.0.1")) {
String sender = mail.getMaybeSender().asString("");
SPFResult result = spf.checkSPF(remoteAddr, sender, helo);
mail.setAttribute(EXPLANATION_ATTRIBUTE, result.getExplanation());
mail.setAttribute(RESULT_ATTRIBUTE, result.getResult());
LOGGER.debug("ip:{} from:{} helo:{} = {}", remoteAddr, sender, helo, result.getResult());
if (addHeader) {
try {
MimeMessage msg = mail.getMessage();
msg.addHeader(result.getHeaderName(), result.getHeaderText());
msg.saveChanges();
} catch (MessagingException e) {
// Ignore not be able to add headers
}
}
}
}
代码示例来源:origin: org.apache.james/james-server-mailets
LOGGER.info("Remote Address: " + mail.getRemoteAddr());
LOGGER.info("Remote Host: " + mail.getRemoteHost());
LOGGER.info("State: " + mail.getState());
代码示例来源:origin: org.apache.james/james-server-jcr
/**
* Writes the mail message to the given mail node.
*
* @param node
* mail node
* @param mail
* mail message
* @throws MessagingException
* if a messaging error occurs
* @throws RepositoryException
* if a repository error occurs
* @throws IOException
* if an IO error occurs
*/
private void setMail(Node node, Mail mail) throws MessagingException, RepositoryException, IOException {
setState(node, mail.getState());
setLastUpdated(node, mail.getLastUpdated());
setError(node, mail.getErrorMessage());
setRemoteHost(node, mail.getRemoteHost());
setRemoteAddr(node, mail.getRemoteAddr());
setSender(node, mail.getSender());
setRecipients(node, mail.getRecipients());
setMessage(node, mail.getMessage());
setAttributes(node, mail);
}
代码示例来源:origin: org.apache.james/james-server-data-jcr
/**
* Writes the mail message to the given mail node.
*
* @param node
* mail node
* @param mail
* mail message
* @throws MessagingException
* if a messaging error occurs
* @throws RepositoryException
* if a repository error occurs
* @throws IOException
* if an IO error occurs
*/
private void setMail(Node node, Mail mail) throws MessagingException, RepositoryException, IOException {
setState(node, mail.getState());
setLastUpdated(node, mail.getLastUpdated());
setError(node, mail.getErrorMessage());
setRemoteHost(node, mail.getRemoteHost());
setRemoteAddr(node, mail.getRemoteAddr());
setSender(node, mail.getMaybeSender());
setRecipients(node, mail.getRecipients());
setMessage(node, mail.getMessage());
setAttributes(node, mail);
}
代码示例来源:origin: org.apache.james/james-server-mailrepository-api
default void checkMailEquality(Mail actual, Mail expected) {
assertSoftly(Throwing.consumer(softly -> {
softly.assertThat(actual.getMessage().getContent()).isEqualTo(expected.getMessage().getContent());
softly.assertThat(actual.getMessageSize()).isEqualTo(expected.getMessageSize());
softly.assertThat(actual.getName()).isEqualTo(expected.getName());
softly.assertThat(actual.getState()).isEqualTo(expected.getState());
softly.assertThat(actual.getAttribute(TEST_ATTRIBUTE)).isEqualTo(expected.getAttribute(TEST_ATTRIBUTE));
softly.assertThat(actual.getErrorMessage()).isEqualTo(expected.getErrorMessage());
softly.assertThat(actual.getRemoteHost()).isEqualTo(expected.getRemoteHost());
softly.assertThat(actual.getRemoteAddr()).isEqualTo(expected.getRemoteAddr());
softly.assertThat(actual.getLastUpdated()).isEqualTo(expected.getLastUpdated());
softly.assertThat(actual.getPerRecipientSpecificHeaders()).isEqualTo(expected.getPerRecipientSpecificHeaders());
}));
}
内容来源于网络,如有侵权,请联系作者删除!