Fix #100
This commit is contained in:
@@ -107,8 +107,8 @@ dependencies {
|
|||||||
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.1'
|
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.1'
|
||||||
|
|
||||||
// E-mail sending
|
// E-mail sending
|
||||||
compile 'com.sun.mail:javax.mail:1.5.6'
|
compile 'com.sun.mail:javax.mail:1.6.2'
|
||||||
compile 'javax.mail:javax.mail-api:1.5.6'
|
compile 'javax.mail:javax.mail-api:1.6.2'
|
||||||
|
|
||||||
// Google Firebase Authentication backend
|
// Google Firebase Authentication backend
|
||||||
compile 'com.google.firebase:firebase-admin:5.3.0'
|
compile 'com.google.firebase:firebase-admin:5.3.0'
|
||||||
|
@@ -26,7 +26,7 @@ import io.kamax.mxisd.config.threepid.connector.EmailSmtpConfig;
|
|||||||
import io.kamax.mxisd.exception.FeatureNotAvailable;
|
import io.kamax.mxisd.exception.FeatureNotAvailable;
|
||||||
import io.kamax.mxisd.exception.InternalServerError;
|
import io.kamax.mxisd.exception.InternalServerError;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -40,6 +40,7 @@ import javax.mail.internet.MimeMessage;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class EmailSmtpConnector implements IEmailConnector {
|
public class EmailSmtpConnector implements IEmailConnector {
|
||||||
@@ -52,7 +53,18 @@ public class EmailSmtpConnector implements IEmailConnector {
|
|||||||
@Autowired
|
@Autowired
|
||||||
public EmailSmtpConnector(EmailSmtpConfig cfg) {
|
public EmailSmtpConnector(EmailSmtpConfig cfg) {
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
session = Session.getInstance(System.getProperties());
|
|
||||||
|
Properties sCfg = new Properties();
|
||||||
|
sCfg.setProperty("mail.smtp.host", cfg.getHost());
|
||||||
|
sCfg.setProperty("mail.smtp.port", Integer.toString(cfg.getPort()));
|
||||||
|
if (StringUtils.isAllEmpty(cfg.getLogin(), cfg.getPassword())) {
|
||||||
|
sCfg.setProperty("mail.smtp.auth", "false");
|
||||||
|
} else {
|
||||||
|
sCfg.setProperty("mail.smtp.user", cfg.getLogin());
|
||||||
|
sCfg.setProperty("mail.smtp.password", cfg.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
session = Session.getInstance(sCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,7 +103,7 @@ public class EmailSmtpConnector implements IEmailConnector {
|
|||||||
transport.setRequireStartTLS(cfg.getTls() > 1);
|
transport.setRequireStartTLS(cfg.getTls() > 1);
|
||||||
|
|
||||||
log.info("Connecting to {}:{}", cfg.getHost(), cfg.getPort());
|
log.info("Connecting to {}:{}", cfg.getHost(), cfg.getPort());
|
||||||
transport.connect(cfg.getHost(), cfg.getPort(), cfg.getLogin(), cfg.getPassword());
|
transport.connect();
|
||||||
try {
|
try {
|
||||||
transport.sendMessage(msg, InternetAddress.parse(recipient));
|
transport.sendMessage(msg, InternetAddress.parse(recipient));
|
||||||
log.info("Invite to {} was sent", recipient);
|
log.info("Invite to {} was sent", recipient);
|
||||||
|
Reference in New Issue
Block a user