Merge pull request #516 from aasaru/develop
FINERACT-699 - new configuration parameters 'fromEmail' and 'fromName'
This commit is contained in:
+12
-1
@@ -25,13 +25,17 @@ public class SMTPCredentialsData {
|
||||
private final String host;
|
||||
private final String port;
|
||||
private final boolean useTLS;
|
||||
private final String fromEmail;
|
||||
private final String fromName;
|
||||
|
||||
public SMTPCredentialsData(final String username, final String password, final String host, final String port, final boolean useTLS) {
|
||||
public SMTPCredentialsData(final String username, final String password, final String host, final String port, final boolean useTLS, String fromEmail, String fromName) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.useTLS = useTLS;
|
||||
this.fromEmail = fromEmail;
|
||||
this.fromName = fromName;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
@@ -54,4 +58,11 @@ public class SMTPCredentialsData {
|
||||
return useTLS;
|
||||
}
|
||||
|
||||
public String getFromEmail() {
|
||||
return fromEmail != null ?fromEmail :username;
|
||||
}
|
||||
|
||||
public String getFromName() {
|
||||
return fromName != null ?fromName :username;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -34,6 +34,8 @@ public class ExternalServicesConstants {
|
||||
public static final String SMTP_HOST = "host";
|
||||
public static final String SMTP_PORT = "port";
|
||||
public static final String SMTP_USE_TLS = "useTLS";
|
||||
public static final String SMTP_FROM_EMAIL = "fromEmail";
|
||||
public static final String SMTP_FROM_NAME = "fromName";
|
||||
|
||||
public static final String SMS_SERVICE_NAME = "MESSAGE_GATEWAY";
|
||||
public static final String SMS_HOST = "host_name";
|
||||
@@ -78,7 +80,7 @@ public class ExternalServicesConstants {
|
||||
}
|
||||
|
||||
public static enum SMTP_JSON_INPUT_PARAMS {
|
||||
USERNAME("username"), PASSWORD("password"), HOST("host"), PORT("port"), USETLS("useTLS");
|
||||
USERNAME("username"), PASSWORD("password"), HOST("host"), PORT("port"), USETLS("useTLS"), FROM_EMAIL("fromEmail"), FROM_NAME("fromName");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
+20
-11
@@ -75,21 +75,30 @@ public class ExternalServicesPropertiesReadPlatformServiceImpl implements Extern
|
||||
String host = null;
|
||||
String port = "25";
|
||||
boolean useTLS = false;
|
||||
String fromEmail = null;
|
||||
String fromName = null;
|
||||
|
||||
while (rs.next()) {
|
||||
if (rs.getString("name").equalsIgnoreCase(ExternalServicesConstants.SMTP_USERNAME)) {
|
||||
username = rs.getString("value");
|
||||
} else if (rs.getString("name").equalsIgnoreCase(ExternalServicesConstants.SMTP_PASSWORD)) {
|
||||
password = rs.getString("value");
|
||||
} else if (rs.getString("name").equalsIgnoreCase(ExternalServicesConstants.SMTP_HOST)) {
|
||||
host = rs.getString("value");
|
||||
} else if (rs.getString("name").equalsIgnoreCase(ExternalServicesConstants.SMTP_PORT)) {
|
||||
port = rs.getString("value");
|
||||
} else if (rs.getString("name").equalsIgnoreCase(ExternalServicesConstants.SMTP_USE_TLS)) {
|
||||
useTLS = Boolean.parseBoolean(rs.getString("value"));
|
||||
String name = rs.getString("name");
|
||||
String value = rs.getString("value");
|
||||
|
||||
if (ExternalServicesConstants.SMTP_USERNAME.equalsIgnoreCase(name)) {
|
||||
username = value;
|
||||
} else if (ExternalServicesConstants.SMTP_PASSWORD.equalsIgnoreCase(name)) {
|
||||
password = value;
|
||||
} else if (ExternalServicesConstants.SMTP_HOST.equalsIgnoreCase(name)) {
|
||||
host = value;
|
||||
} else if (ExternalServicesConstants.SMTP_PORT.equalsIgnoreCase(name)) {
|
||||
port = value;
|
||||
} else if (ExternalServicesConstants.SMTP_USE_TLS.equalsIgnoreCase(name)) {
|
||||
useTLS = Boolean.parseBoolean(value);
|
||||
} else if (ExternalServicesConstants.SMTP_FROM_EMAIL.equalsIgnoreCase(name)) {
|
||||
fromEmail = value;
|
||||
} else if (ExternalServicesConstants.SMTP_FROM_NAME.equalsIgnoreCase(name)) {
|
||||
fromName = value;
|
||||
}
|
||||
}
|
||||
return new SMTPCredentialsData(username, password, host, port, useTLS);
|
||||
return new SMTPCredentialsData(username, password, host, port, useTLS, fromEmail, fromName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -60,7 +60,6 @@ public class GmailBackedPlatformEmailService implements PlatformEmailService {
|
||||
public void sendDefinedEmail(EmailDetail emailDetails) {
|
||||
final Email email = new SimpleEmail();
|
||||
final SMTPCredentialsData smtpCredentialsData = this.externalServicesReadPlatformService.getSMTPCredentials();
|
||||
final String authuserName = smtpCredentialsData.getUsername();
|
||||
|
||||
final String authuser = smtpCredentialsData.getUsername();
|
||||
final String authpwd = smtpCredentialsData.getPassword();
|
||||
@@ -74,7 +73,7 @@ public class GmailBackedPlatformEmailService implements PlatformEmailService {
|
||||
if(smtpCredentialsData.isUseTLS()){
|
||||
email.getMailSession().getProperties().put("mail.smtp.starttls.enable", "true");
|
||||
}
|
||||
email.setFrom(authuser, authuserName);
|
||||
email.setFrom(smtpCredentialsData.getFromEmail(), smtpCredentialsData.getFromName());
|
||||
|
||||
email.setSubject(emailDetails.getSubject());
|
||||
email.setMsg(emailDetails.getBody());
|
||||
|
||||
Reference in New Issue
Block a user