Skip to content

Commit

Permalink
Fix potential slow/hanging host resolution when sending mail (fixes #358
Browse files Browse the repository at this point in the history
)
  • Loading branch information
marcelmay committed Jan 4, 2021
1 parent 5670467 commit e1a2e22
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ public Properties configureJavaMailSessionProperties(Properties properties, bool
// Set local host address (makes tests much faster. If this is not set java mail always looks for the address)
props.setProperty(MAIL_DOT + getProtocol() + ".localaddress", ServerSetup.getLocalHostAddress());
props.setProperty(MAIL_DOT + getProtocol() + ".port", String.valueOf(getPort()));
props.setProperty(MAIL_DOT + getProtocol() + ".host", String.valueOf(getBindAddress()));
final String bindAddress = getBindAddress();
props.setProperty(MAIL_DOT + getProtocol() + ".host", String.valueOf(bindAddress));
// Fixes slow Transport.send->UniqueValue.getUniqueMessageIDValue->javax.mail.internet.InternetAddress.getLocalAddress
if(!props.containsKey("mail.host")&&null!=bindAddress) {
props.setProperty("mail.host", bindAddress);
}

if (isSecure()) {
props.put(MAIL_DOT + getProtocol() + ".starttls.enable", Boolean.TRUE);
Expand Down

0 comments on commit e1a2e22

Please sign in to comment.