Skip to content

Commit

Permalink
SAK-50284 Kernel email Message-ID must contain angle brackets (sakaip…
Browse files Browse the repository at this point in the history
…roject#12720)

Co-authored-by: Earle Nietzel <[email protected]>
Co-authored-by: Adrian Fish <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2024
1 parent 9ebce10 commit 5bf0159
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,9 @@ protected void sendMessageAndLog(InternetAddress[] to, long start, MimeMessage m
buf.append(" with ").append(parts.getCount() - 1).append(" attachments");
}
}
catch (IOException ioe) {}
catch (IOException ioe) {
log.debug("could not read message contents, {}", ioe);
}

if (log.isDebugEnabled())
{
Expand Down Expand Up @@ -1608,8 +1610,8 @@ else if (canUseCharset(message, CharacterSet.WINDOWS_1252) && canUseCharset(getS
/**
* Override MimeMessage Message-ID to use Sakai serverId instead of hostname
* https://javaee.github.io/javamail/FAQ#msgid
* @throws MessagingException
*/
@Override
protected void updateMessageID() throws MessagingException
{
StringBuilder s = new StringBuilder();
Expand All @@ -1621,9 +1623,10 @@ protected void updateMessageID() throws MessagingException
append(System.currentTimeMillis()).
append('@').
append(serverConfigurationService.getServerName());
setHeader("Message-ID", s.toString());
setHeader("Message-ID", "<" + s + ">");
}

@Override
protected void updateHeaders() throws MessagingException
{
super.updateHeaders();
Expand Down Expand Up @@ -1672,17 +1675,12 @@ private void addEncodedHeader(String header, String name) throws MessagingExcept
}
}
}
catch (MessagingException e)
{
log.error("Email.MyMessage: exception: " + e, e);
addHeaderLine(header);
}
catch (UnsupportedEncodingException e)
catch (MessagingException | UnsupportedEncodingException e)
{
log.error("Email.MyMessage: exception: " + e, e);
log.error("Email.MyMessage: exception: {}", e, e);
addHeaderLine(header);
}
}
}
}

public String propName(String propNameTemplate)
Expand All @@ -1692,7 +1690,6 @@ public String propName(String propNameTemplate)

public String propName(String propNameTemplate, String protocol)
{
String formattedName = String.format(propNameTemplate, protocol);
return formattedName;
return String.format(propNameTemplate, protocol);
}
}

0 comments on commit 5bf0159

Please sign in to comment.