From 3a0369c0d7cce9e13a39a9d8867b5abeb09189fe Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 18 Sep 2015 10:14:52 +0200 Subject: [PATCH] OO-1691: add configuration for smtp start tls and timeout --- src/main/java/org/olat/core/util/_spring/utilCorecontext.xml | 3 ++- .../org/olat/core/util/mail/manager/MailManagerImpl.java | 5 +++++ src/main/resources/serviceconfig/olat.properties | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml b/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml index b4dcd6f50c0..83bd3edbf9e 100644 --- a/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml +++ b/src/main/java/org/olat/core/util/_spring/utilCorecontext.xml @@ -24,11 +24,12 @@ <property name="mailConfig"> <map> <entry key="mailhost" value="${smtp.host}"/> - <entry key="mailTimeout" value="8000"/> <!-- timeout in milliseconds --> + <entry key="mailTimeout" value="${smtp.timeout}"/> <!-- timeout in milliseconds --> <entry key="smtpUser" value="${smtp.user}"/> <entry key="smtpPwd" value="${smtp.pwd}"/> <entry key="sslEnabled" value="${smtp.sslEnabled}"/> <entry key="sslCheckCertificate" value="${smtp.sslCheckCertificate}"/> + <entry key="smtpStarttls" value="${smtp.starttls}"/> <entry key="mailFrom" value="${fromemail}"/> <entry key="mailFromName" value="${fromname}"/> <entry key="mailReplyTo" value="${adminemail}"/> diff --git a/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java b/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java index 0bf659b01df..8ab00be68b1 100644 --- a/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java +++ b/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java @@ -1448,6 +1448,7 @@ public class MailManagerImpl extends BasicManager implements MailManager { String mailhostTimeout = WebappHelper.getMailConfig("mailTimeout"); boolean sslEnabled = Boolean.parseBoolean(WebappHelper.getMailConfig("sslEnabled")); boolean sslCheckCertificate = Boolean.parseBoolean(WebappHelper.getMailConfig("sslCheckCertificate")); + boolean startTls = Boolean.parseBoolean(WebappHelper.getMailConfig("smtpStarttls")); Authenticator smtpAuth; if (WebappHelper.isMailHostAuthenticationEnabled()) { @@ -1465,6 +1466,10 @@ public class MailManagerImpl extends BasicManager implements MailManager { p.put("mail.smtp.connectiontimeout", mailhostTimeout); p.put("mail.smtp.ssl.enable", sslEnabled); p.put("mail.smtp.ssl.checkserveridentity", sslCheckCertificate); + if(startTls) { + p.put("mail.smtp.starttls.enable", "true"); + } + Session mailSession; if (smtpAuth == null) { mailSession = javax.mail.Session.getInstance(p); diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index 4bff2de2495..962d2c07523 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -123,6 +123,9 @@ smtp.pwd= # enable SSL if your smtp server supports it smtp.sslEnabled=false smtp.sslCheckCertificate=false +smtp.starttls=false +# timeout in milliseconds +smtp.timeout=8000 # system mails will be sent from this address (from local domain with valid reverse dns): fromemail=no-reply@your.domain # the plain text name of the from mail address usually displayed by the email client -- GitLab