public void sendNotificationMail( String toList, String ccList, String bccList, String emailSubject, String emailText, boolean isException, String attachmentpos) throws Exception { try { // In case of Exception email, Read the Property file to get To/CC/Sub from property file. if (isException) { PropertyFileReader propertyReader = PropertyFileReader.getInstance(); toList = propertyReader.getStringProperty("errorMailTo"); ccList = propertyReader.getStringProperty("errorMailCC"); emailSubject = propertyReader.getStringProperty("errorMailSubject"); } // bcc & attachmentPos is hardcoded NULL in case of exception email sendMail(toList, ccList, bccList, emailSubject, emailText, null); /*emailNotificationBean.setAllValues(toList, ccList, bccList, emailSubject, emailText); sendMail(toList, ccList, bccList, emailSubject, emailText, attachmentpos); /*NotificationCenterBean emailNotificationBean = new NotificationCenterBean(); emailNotificationBean.setAllValues(toList, ccList, bccList, emailSubject, emailText); System.out.println(emailNotificationBean); notificationCenterService.saveNotification(emailNotificationBean);*/ } catch (Exception e) { e.printStackTrace(); } }
private void doInit() throws Exception { PropertyFileReader propertReader = PropertyFileReader.getInstance(); emailId = propertReader.getStringProperty("errorMailFrom"); password = propertReader.getStringProperty("errorMailPassword"); protocol = propertReader.getStringProperty("mailProtocol"); host = propertReader.getStringProperty("mailHost"); smtpHost = propertReader.getStringProperty("mailSmtpHost"); smtpPortNo = propertReader.getIntProperty("mailSmtpPortNo"); props = System.getProperties(); props.setProperty("mail.store.protocol", protocol); Authenticator auth = new EmailAuthentication(emailId, password); session = Session.getDefaultInstance(props, auth); store = session.getStore("pop3"); store.connect(host, emailId, password); props.put("mail.smtp.port", smtpPortNo); props.put("mail.smtp.host", smtpHost); props.put("mail.smtp.auth", "true"); props.put("mail.debug", "false"); props.put("mail.smtp.ssl.enable", "false"); }