francisguchie commented on a change in pull request #1597:
URL: https://github.com/apache/fineract/pull/1597#discussion_r579083354
##########
File path:
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/GmailBackedPlatformEmailService.java
##########
@@ -55,31 +54,42 @@ public void sendToUserAccount(String organisationName,
String contactName, Strin
@Override
public void sendDefinedEmail(EmailDetail emailDetails) {
- final Email email = new SimpleEmail();
final SMTPCredentialsData smtpCredentialsData =
this.externalServicesReadPlatformService.getSMTPCredentials();
final String authuser = smtpCredentialsData.getUsername();
final String authpwd = smtpCredentialsData.getPassword();
- // Very Important, Don't use email.setAuthentication()
- email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd));
- email.setDebug(false); // true if you want to debug
- email.setHostName(smtpCredentialsData.getHost());
+ JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
+ mailSender.setHost(smtpCredentialsData.getHost()); // smtp.gmail.com
+ mailSender.setPort(Integer.parseInt(smtpCredentialsData.getPort()));
// 587
+
+ // Important: Enable less secure app access for the gmail account used
in the following authentication
+
+ mailSender.setUsername(authuser); // use valid gmail address
+ mailSender.setPassword(authpwd); // use password of the above gmail
account
+
+ Properties props = mailSender.getJavaMailProperties();
+ props.put("mail.transport.protocol", "smtp");
+ props.put("mail.smtp.auth", "true");
+ props.put("mail.debug", "true");
try {
if (smtpCredentialsData.isUseTLS()) {
- // FINERACT-1070: NOT email.setSSLOnConnect(true);
email.setSslSmtpPort(smtpCredentialsData.getPort());
- email.setStartTLSRequired(true);
+ if (smtpCredentialsData.getPort().equals("465")) {
Review comment:
> I don't think hardcoding ports is a good idea...
@ptuomola i do agree with you and that is why i created an issue an the
jira about this https://issues.apache.org/jira/browse/FINERACT-1070 which when
checked @vorburger agreed
I was thinking that me and @BLasan were trying to get things done (by hard
cording) and once we are thoroughly done, we shall make sure that variables are
picked from the database as per the users settings
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]