Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions api/src/org/labkey/api/util/SmtpTransportProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String getPropertyName()
@Override
public String getDescription()
{
return "One property for each JavaMail SMTP setting, documented here: https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html";
return "No longer supported. Configure SMTP settings in application.properties.";
}
}

Expand All @@ -69,31 +69,30 @@ public String getName()
@Override
public void loadConfiguration()
{
try
{
// Load from startup properties group "mail_smtp"
ModuleLoader.getInstance().handleStartupProperties(
new LenientStartupPropertyHandler<>("mail_smtp", new SmtpStartupProperty())
// TODO: Startup failure if SMTP startup properties are present, for now. Remove in 26.11.
ModuleLoader.getInstance().handleStartupProperties(
new LenientStartupPropertyHandler<>("mail_smtp", new SmtpStartupProperty())
{
@Override
public void handle(Collection<StartupPropertyEntry> entries)
{
@Override
public void handle(Collection<StartupPropertyEntry> entries)
if (!entries.isEmpty())
{
entries.forEach(entry ->
_properties.put("mail.smtp." + entry.getName(), entry.getValue()));
throw new ConfigurationException("Configuring SMTP via startup properties is no longer supported. Use application.properties.");
}
});
}
});

// Fallback: check ServletContext for SMTP settings
if (_properties.isEmpty())
try
{
// Load SMTP settings from ServletContext (populated from application.properties)
ServletContext context = ModuleLoader.getServletContext();
Enumeration<String> names = Objects.requireNonNull(context).getInitParameterNames();
while (names.hasMoreElements())
{
ServletContext context = ModuleLoader.getServletContext();
Enumeration<String> names = Objects.requireNonNull(context).getInitParameterNames();
while (names.hasMoreElements())
{
String name = names.nextElement();
if (name.startsWith("mail.smtp."))
_properties.put(name, context.getInitParameter(name));
}
String name = names.nextElement();
if (name.startsWith("mail.smtp."))
_properties.put(name, context.getInitParameter(name));
}

// Create session if configured
Expand Down