This is an automated email from the ASF dual-hosted git repository.
kao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 6b41a8e011 JAMES-3792 Remote and Local delivery should log MIME
MessageId
6b41a8e011 is described below
commit 6b41a8e01113c9089800a413af4b858697af8a49
Author: Karsten Otto <[email protected]>
AuthorDate: Mon Jul 25 12:34:54 2022 +0200
JAMES-3792 Remote and Local delivery should log MIME MessageId
---
.../transport/mailets/delivery/SimpleMailStore.java | 13 +++++++++++--
.../mailets/remote/delivery/MailDelivrerToHost.java | 17 ++++++++++++++---
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
index 7f79657955..96edbbeb4a 100644
---
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
+++
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
@@ -100,14 +100,23 @@ public class SimpleMailStore implements MailStore {
return Mono.from(mailboxAppender.append(mail.getMessage(),
username, locatedFolder))
.doOnSuccess(ids -> {
metric.increment();
- LOGGER.info("Local delivered mail {} successfully from {}
to {} in folder {} with composedMessageId {}", mail.getName(),
- mail.getMaybeSender().asString(),
recipient.asPrettyString(), locatedFolder, ids);
+ LOGGER.info("Local delivered mail {} with messageId {}
successfully from {} to {} in folder {} with composedMessageId {}",
+ mail.getName(), getMessageId(mail),
mail.getMaybeSender().asString(), recipient.asPrettyString(), locatedFolder,
ids);
})
.then();
} catch (MessagingException e) {
throw new RuntimeException("Could not retrieve mail message
content", e);
}
}
+
+ private String getMessageId(Mail mail) {
+ try {
+ return mail.getMessage().getMessageID();
+ } catch (MessagingException e) {
+ LOGGER.debug("failed to extract messageId from message {}",
mail.getName(), e);
+ return null;
+ }
+ }
private String locateFolder(Username username, Mail mail) {
return AttributeUtils
diff --git
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
index 4f50680d35..cf75232d89 100644
---
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
+++
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrerToHost.java
@@ -106,8 +106,9 @@ public class MailDelivrerToHost {
public ExecutionResult tryDeliveryToHost(Mail mail,
Collection<InternetAddress> addr, HostAddress outgoingMailServer) throws
MessagingException {
Session session = selectSession(outgoingMailServer);
Properties props = getPropertiesForMail(mail, session);
- LOGGER.debug("Attempting delivery of {} to host {} at {} from {}",
- mail.getName(), outgoingMailServer.getHostName(),
outgoingMailServer.getHost(), props.get(inContext(session, "mail.smtp.from")));
+ LOGGER.debug("Attempting delivery of {} with messageId {} to host {}
at {} from {}",
+ mail.getName(), getMessageId(mail),
outgoingMailServer.getHostName(),
+ outgoingMailServer.getHost(), props.get(inContext(session,
"mail.smtp.from")));
// Many of these properties are only in later JavaMail versions
// "mail.smtp.ehlo" //default true
@@ -125,7 +126,8 @@ public class MailDelivrerToHost {
} else {
transport.sendMessage(adaptToTransport(mail.getMessage(),
transport), addr.toArray(InternetAddress[]::new));
}
- LOGGER.debug("Mail ({}) sent successfully to {} at {} from {} for
{}", mail.getName(), outgoingMailServer.getHostName(),
+ LOGGER.info("Mail ({}) with messageId {} sent successfully to {}
at {} from {} for {}",
+ mail.getName(), getMessageId(mail),
outgoingMailServer.getHostName(),
outgoingMailServer.getHost(), props.get(inContext(session,
"mail.smtp.from")), mail.getRecipients());
} finally {
closeTransport(mail, outgoingMailServer, transport);
@@ -134,6 +136,15 @@ public class MailDelivrerToHost {
return ExecutionResult.success();
}
+ private String getMessageId(Mail mail) {
+ try {
+ return mail.getMessage().getMessageID();
+ } catch (MessagingException e) {
+ LOGGER.debug("failed to extract messageId from message {}",
mail.getName(), e);
+ return null;
+ }
+ }
+
private Session selectSession(HostAddress host) throws MessagingException {
try {
if (host.getProtocol().equalsIgnoreCase("smtps")) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]