Skip to content
Snippets Groups Projects
Commit 4cfccd57 authored by srosse's avatar srosse
Browse files

OO-1691: add an option tp specify the port of the smtp host, add an additional...

OO-1691: add an option tp specify the port of the smtp host, add an additional optional for start tls to trust the host
parent 5976047d
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<property name="mailConfig"> <property name="mailConfig">
<map> <map>
<entry key="mailhost" value="${smtp.host}"/> <entry key="mailhost" value="${smtp.host}"/>
<entry key="mailport" value="${smtp.port}"/>
<entry key="mailTimeout" value="${smtp.timeout}"/> <!-- timeout in milliseconds --> <entry key="mailTimeout" value="${smtp.timeout}"/> <!-- timeout in milliseconds -->
<entry key="smtpUser" value="${smtp.user}"/> <entry key="smtpUser" value="${smtp.user}"/>
<entry key="smtpPwd" value="${smtp.pwd}"/> <entry key="smtpPwd" value="${smtp.pwd}"/>
......
...@@ -1445,6 +1445,7 @@ public class MailManagerImpl extends BasicManager implements MailManager { ...@@ -1445,6 +1445,7 @@ public class MailManagerImpl extends BasicManager implements MailManager {
*/ */
private MimeMessage createMessage(Address bounceAdress) { private MimeMessage createMessage(Address bounceAdress) {
String mailhost = WebappHelper.getMailConfig("mailhost"); String mailhost = WebappHelper.getMailConfig("mailhost");
String mailport = WebappHelper.getMailConfig("mailport");
String mailhostTimeout = WebappHelper.getMailConfig("mailTimeout"); String mailhostTimeout = WebappHelper.getMailConfig("mailTimeout");
boolean sslEnabled = Boolean.parseBoolean(WebappHelper.getMailConfig("sslEnabled")); boolean sslEnabled = Boolean.parseBoolean(WebappHelper.getMailConfig("sslEnabled"));
boolean sslCheckCertificate = Boolean.parseBoolean(WebappHelper.getMailConfig("sslCheckCertificate")); boolean sslCheckCertificate = Boolean.parseBoolean(WebappHelper.getMailConfig("sslCheckCertificate"));
...@@ -1462,12 +1463,16 @@ public class MailManagerImpl extends BasicManager implements MailManager { ...@@ -1462,12 +1463,16 @@ public class MailManagerImpl extends BasicManager implements MailManager {
Properties p = new Properties(); Properties p = new Properties();
p.put("mail.smtp.from", bounceAdress.toString()); p.put("mail.smtp.from", bounceAdress.toString());
p.put("mail.smtp.host", mailhost); p.put("mail.smtp.host", mailhost);
if(StringHelper.containsNonWhitespace(mailport)) {
p.put("mail.smtp.port", mailport);
}
p.put("mail.smtp.timeout", mailhostTimeout); p.put("mail.smtp.timeout", mailhostTimeout);
p.put("mail.smtp.connectiontimeout", mailhostTimeout); p.put("mail.smtp.connectiontimeout", mailhostTimeout);
p.put("mail.smtp.ssl.enable", sslEnabled); p.put("mail.smtp.ssl.enable", sslEnabled);
p.put("mail.smtp.ssl.checkserveridentity", sslCheckCertificate); p.put("mail.smtp.ssl.checkserveridentity", sslCheckCertificate);
if(startTls) { if(startTls) {
p.put("mail.smtp.starttls.enable", "true"); p.put("mail.smtp.starttls.enable", "true");
p.put("mail.smtp.ssl.trust", mailhost);
} }
Session mailSession; Session mailSession;
......
...@@ -117,6 +117,7 @@ session.timeout.authenticated=7200 ...@@ -117,6 +117,7 @@ session.timeout.authenticated=7200
# mail support can be disabled by leaving the following entry blank or # mail support can be disabled by leaving the following entry blank or
# setting it to the keyword 'disabled' (without quotes!) # setting it to the keyword 'disabled' (without quotes!)
smtp.host=localhost smtp.host=localhost
smtp.port=
# if required by your local SMTP you may need to provide credentials # if required by your local SMTP you may need to provide credentials
smtp.user= smtp.user=
smtp.pwd= smtp.pwd=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment