diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index 9ba76f99fb9..0d45a2efc1d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -136,6 +136,7 @@ public final class DeviceManagementConstants { public static final String POLICY_VIOLATE_TEMPLATE = "policy-violating-notifier"; public static final String USER_WELCOME_TEMPLATE = "user-welcome"; public static final String DEFAULT_ENROLLMENT_TEMPLATE = "default-enrollment-invitation"; + public static final String ENROLLMENT_GUIDE_TEMPLATE = "enrollment-guide"; } public static final class OperationAttributes { 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 ded3d067fe7..2b5c0dffae3 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 @@ -1583,38 +1583,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException { - String to = "oshani@entgra.io"; - String from = "oshsilva1996@gmail.com"; - String host = "smtp.gmail.com"; - Properties properties = System.getProperties(); - - // Setup mail server - properties.put("mail.smtp.host", host); - properties.put("mail.smtp.port", "465"); - properties.put("mail.smtp.ssl.enable", "true"); - properties.put("mail.smtp.auth", "true"); - - Session session = Session.getInstance(properties, new javax.mail.Authenticator() { - - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication("oshsilva1996@gmail.com", "layzvxhcxlwzkgwf"); - } - - }); - - // Used to debug SMTP issues - session.setDebug(true); + Properties props = new Properties(); + props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")"); + props.setProperty("enrollment-guide", enrolmentGuide); try { - 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.setText(enrolmentGuide); - Transport.send(message); - } catch (MessagingException e) { - String msg = "Error occurred while sending message to support dev group"; - log.error(msg, e); + EmailMetaInfo metaInfo = new EmailMetaInfo("support-dev-group@entgra.io", props); + sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.ENROLLMENT_GUIDE_TEMPLATE, metaInfo); + + } catch (ConfigurationManagementException e) { + String msg = "Error occurred while sending the mail."; + log.error(msg); throw new DeviceManagementException(msg, e); } } diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm new file mode 100644 index 00000000000..f4f16cc8d7b --- /dev/null +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm @@ -0,0 +1,34 @@ +#* + Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + you may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*# + + $mail-subject + + + + Enrollment Questions and Answers + + +
+ $enrollment-guide +
+ + + ]]> + +