From 5dab9433a44a458a0d3e985346e14d4f8c18cca7 Mon Sep 17 00:00:00 2001 From: osh Date: Fri, 17 Mar 2023 03:34:18 +0530 Subject: [PATCH] Update email subject fixes https://roadmap.entgra.net/issues/9939 --- .../DeviceManagementProviderServiceImpl.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 8e38720f40a..ded3d067fe7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1581,16 +1581,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public void sendEnrolmentGuide(String enrolmentGuide) { + public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException { String to = "oshani@entgra.io"; - - // Sender's email ID needs to be mentioned String from = "oshsilva1996@gmail.com"; - String host = "smtp.gmail.com"; - - // Get system properties Properties properties = System.getProperties(); // Setup mail server @@ -1599,7 +1594,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv properties.put("mail.smtp.ssl.enable", "true"); properties.put("mail.smtp.auth", "true"); - // Get the Session object Session session = Session.getInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { @@ -1615,11 +1609,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); - message.setSubject("Enrollment Guide Triggered " + ++count); + message.setSubject("[Enrollment Guide Triggered] (#" + ++count + ")"); message.setText(enrolmentGuide); Transport.send(message); - } catch (MessagingException mex) { - mex.printStackTrace(); + } catch (MessagingException e) { + String msg = "Error occurred while sending message to support dev group"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); } }