List of usage examples for org.springframework.mail SimpleMailMessage setText
@Override public void setText(String text)
From source file:org.gbif.portal.service.impl.LogManagerImpl.java
/** * Sends a log message to the appropriate recipient * /*from www . j a va 2 s . c o m*/ * TODO Should really make use of velocity templating * * @param message GbifLogMessage */ protected void sendFeedbackMessage(GbifLogMessage message, User user, String url) { // for safety if (user == null) { return; } List<String> toEmailAddresses = new ArrayList<String>(); toEmailAddresses.add("sib+dataportal@humboldt.org.co"); List<String> ccEmailAddresses = new ArrayList<String>(); if (message.getDataResourceId() != 0) { String dataResourceKey = new Long(message.getDataResourceId()).toString(); List<DataResourceAgentDTO> agents = dataResourceManager.getAgentsForDataResource(dataResourceKey); if (agents != null) { for (DataResourceAgentDTO agent : agents) { if (agent.getAgentType() == AgentType.DATAADMINISTRATOR.getValue()) { toEmailAddresses.add(processEmail(agent.getAgentEmail())); } else { ccEmailAddresses.add(processEmail(agent.getAgentEmail())); } } if (toEmailAddresses.size() == 0 && ccEmailAddresses.size() > 0) { toEmailAddresses = ccEmailAddresses; ccEmailAddresses = new ArrayList<String>(); } } } if (toEmailAddresses.size() == 0 && message.getDataProviderId() != 0) { String dataProviderKey = new Long(message.getDataProviderId()).toString(); List<DataProviderAgentDTO> agents = dataResourceManager.getAgentsForDataProvider(dataProviderKey); if (agents != null) { for (DataProviderAgentDTO agent : agents) { if (agent.getAgentType() == AgentType.DATAADMINISTRATOR.getValue()) { toEmailAddresses.add(processEmail(agent.getAgentEmail())); } else { ccEmailAddresses.add(processEmail(agent.getAgentEmail())); } } if (toEmailAddresses.size() == 0 && ccEmailAddresses.size() > 0) { toEmailAddresses = ccEmailAddresses; ccEmailAddresses = new ArrayList<String>(); } } } if (toEmailAddresses.size() != 0) { ccEmailAddresses.addAll(portalEmailAddresses); ccEmailAddresses.removeAll(toEmailAddresses); SimpleMailMessage providerMessage = new SimpleMailMessage(providerTemplateMessage); providerMessage.setTo(toEmailAddresses.toArray(new String[toEmailAddresses.size()])); //user that submitted feedback should also be CCed if (user.getEmail() != null) { ccEmailAddresses.add(processEmail(user.getEmail())); } providerMessage.setCc(ccEmailAddresses.toArray(new String[ccEmailAddresses.size()])); // TODO - NLS and portal URL StringBuffer subjectBuffer = new StringBuffer(); SimpleMailMessage userMessage = new SimpleMailMessage(userTemplateMessage); userMessage.setTo(user.getEmail()); subjectBuffer.append("Comentarios desde el Portal de Datos del SIB Colombia - "); StringBuffer textBuffer = new StringBuffer(); textBuffer.append( "El siguiente mensaje ha sido enviado a travs del Portal del Datos del SIB Colombia.\n\n"); if (user != null) { textBuffer.append(" Usuario: "); textBuffer.append(user.getName()); textBuffer.append(" ("); textBuffer.append(user.getEmail()); textBuffer.append(")\n\n"); } if (message.getDataProviderId() != null && message.getDataProviderId() != 0) { try { DataProviderDTO dto = dataResourceManager .getDataProviderFor(new Long(message.getDataProviderId()).toString()); textBuffer.append(" Publicador de datos: "); textBuffer.append(dto.getName()); textBuffer.append("\n"); String portalUrl = " URL en el portal: " + url + "/datasets/provider/"; //textBuffer.append(" Portal URL: http://data.gbif.org/datasets/provider/"); textBuffer.append(portalUrl); textBuffer.append(dto.getKey()); textBuffer.append("\n\n"); } catch (Exception e) { // ignore } } if (message.getDataResourceId() != null && message.getDataResourceId() != 0) { try { DataResourceDTO dto = dataResourceManager .getDataResourceFor(new Long(message.getDataResourceId()).toString()); textBuffer.append(" Conjunto de datos: "); textBuffer.append(dto.getName()); textBuffer.append("\n"); String portalUrl = " URL en el portal: " + url + "/datasets/resource/"; //textBuffer.append(" Portal URL: http://data.gbif.org/datasets/resource/"); textBuffer.append(portalUrl); textBuffer.append(dto.getKey()); textBuffer.append("\n\n"); } catch (Exception e) { // ignore } } if (message.getOccurrenceId() != null && message.getOccurrenceId() != 0) { try { OccurrenceRecordDTO dto = occurrenceManager .getOccurrenceRecordFor(new Long(message.getOccurrenceId()).toString()); subjectBuffer.append("catalogue number: "); subjectBuffer.append(dto.getCatalogueNumber()); subjectBuffer.append(" "); textBuffer.append(" Occurrence record: "); textBuffer.append(dto.getInstitutionCode()); textBuffer.append(" / "); textBuffer.append(dto.getCollectionCode()); textBuffer.append(" / "); textBuffer.append(dto.getCatalogueNumber()); textBuffer.append("\n"); String portalUrl = " URL en el portal: " + url + "/occurrences/"; //textBuffer.append(" Portal URL: http://data.gbif.org/occurrences/"); textBuffer.append(portalUrl); textBuffer.append(dto.getKey()); textBuffer.append("\n\n"); } catch (Exception e) { // ignore } } if (message.getTaxonConceptId() != null && message.getTaxonConceptId() != 0) { try { TaxonConceptDTO dto = taxonomyManager .getTaxonConceptFor(new Long(message.getTaxonConceptId()).toString()); subjectBuffer.append("taxon: "); subjectBuffer.append(dto.getTaxonName()); textBuffer.append(" Taxon: "); textBuffer.append(dto.getTaxonName()); textBuffer.append("\n"); String portalUrl = " URL en el portal: " + url + "/species/"; //textBuffer.append(" Portal URL: http://data.gbif.org/species/"); textBuffer.append(portalUrl); textBuffer.append(dto.getKey()); textBuffer.append("\n\n"); } catch (Exception e) { // ignore } } textBuffer.append(message.getMessage()); providerMessage.setSubject(subjectBuffer.toString()); providerMessage.setText(textBuffer.toString()); userMessage.setSubject(subjectBuffer.toString()); userMessage.setText("Gracias por su comentario. El mensaje ha sido" + " enviado en su nombre, al publicador de datos apropiado.\n\n"); try { mailSender.send(providerMessage); mailSender.send(userMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); } } }
From source file:org.gbif.portal.service.impl.LogManagerImpl.java
/** * Sends a verification message to the User given * // w w w.ja v a 2 s . c o m * TODO Should really make use of velocity templating * * @param user to send to */ protected void sendVerificationMessage(User user, String url) { if (user != null) { SimpleMailMessage verificationMessage = new SimpleMailMessage(userTemplateMessage); verificationMessage.setTo(user.getEmail()); verificationMessage.setSubject( "Confirme la direccin de correo electrnico para el Portal de Datos del SIB Colombia "); // todo verificationMessage.setText( "Por favor visite el siguiente enlace para confirmar su direccin de correo electrnico:\n" + url + "/feedback/verification/" + user.getId() + "/" + UserUtils.getCodeFor(user.getName(), user.getEmail())); try { mailSender.send(verificationMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); } } }
From source file:org.gbif.portal.web.controller.registration.RegistrationController.java
/** * Forgotten password.// w ww . j a v a 2 s . co m * * @param request * @param response * @return * @throws Exception */ public ModelAndView forgottenPassword(HttpServletRequest request, HttpServletResponse response) throws Exception { if (!isFormSubmission(request)) { ModelAndView mav = new ModelAndView("forgottenPassword"); return mav; } String email = request.getParameter("email"); List<UserLogin> uls = ldapUtils.getUsernamePasswordForEmail(email); if (uls.isEmpty()) { ModelAndView mav = new ModelAndView("forgottenPassword"); mav.addObject("email", email); mav.addObject("unrecognised", true); return mav; } for (UserLogin ul : uls) { // reset password String newPassword = generatePassword(ul.getUsername()); ul.setPassword(newPassword); ldapUtils.updateUser(ul); // send verification email SimpleMailMessage verificationMessage = new SimpleMailMessage(userTemplateMessage); verificationMessage.setTo(email); String encryptedPassword = passwordUtils.encryptPassword(ul.getPassword(), true); verificationMessage.setSubject("Details for GBIF Data Portal"); verificationMessage.setText("Please click here to login:\n\n" + "http://" + request.getHeader("host") + request.getContextPath() + "/register/" + "?u=" + ul.getUsername() + "&p=" + encryptedPassword + "\n\nUsername: " + ul.getUsername() + "\nPassword: " + ul.getPassword()); try { mailSender.send(verificationMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); ModelAndView mav = new ModelAndView("emailDetailsFailureView"); mav.addObject("email", email); return mav; } } ModelAndView mav = new ModelAndView("emailDetailsSuccessView"); mav.addObject("email", email); return mav; }
From source file:org.gbif.portal.web.controller.registration.RegistrationController.java
/** * Create a new user in LDAP.//from w w w.j ava2 s . c o m * * @param request * @param response * @return * @throws Exception */ public ModelAndView newUser(HttpServletRequest request, HttpServletResponse response) throws Exception { if (!isFormSubmission(request)) { ModelAndView mav = new ModelAndView("newUser"); UserLogin ul = new UserLogin(); mav.addObject("user", ul); return mav; } UserLogin ul = new UserLogin(); ServletRequestDataBinder binder = createBinder(request, ul); binder.bind(request); BindingResult result = binder.getBindingResult(); String systemUserName = getSystemUserName(ul.getUsername()); String suggestedUsername = null; // validate if (StringUtils.isEmpty(ul.getUsername())) { result.rejectValue("username", ErrorMessageKeys.MUST_BE_SPECIFIED); } else if (ul.getUsername().length() < minimumUsernameLength) { result.rejectValue("username", ErrorMessageKeys.MUST_BE_MINIMIUM_LENGTH); } else if (!validateUsername(ul.getUsername())) { result.rejectValue("username", ErrorMessageKeys.CONTAINS_INVALID_CHARS); } else if (ldapUtils.userNameInUse(systemUserName)) { // iterate until a username available for (int i = 0; i < Integer.MAX_VALUE; i++) { suggestedUsername = getSystemUserName(ul.getUsername() + i); if (!ldapUtils.userNameInUse(suggestedUsername)) { break; } } result.rejectValue("username", ErrorMessageKeys.USERNAME_IN_USE); } if (StringUtils.isEmpty(ul.getFirstName())) { result.rejectValue("firstName", ErrorMessageKeys.MUST_BE_SPECIFIED); } if (StringUtils.isEmpty(ul.getSurname())) { result.rejectValue("surname", ErrorMessageKeys.MUST_BE_SPECIFIED); } if (!StringUtils.isEmpty(ul.getEmail())) { Pattern p = Pattern.compile(".+@.+\\.[a-z]+"); Matcher m = p.matcher(ul.getEmail()); boolean validEmail = m.matches(); if (!validEmail) result.rejectValue("email", ErrorMessageKeys.INVALID_VALUE); } else { result.rejectValue("email", ErrorMessageKeys.MUST_BE_SPECIFIED); } if (StringUtils.isEmpty(ul.getPassword())) { result.rejectValue("password", ErrorMessageKeys.MUST_BE_SPECIFIED); } else if (!validatePassword(ul.getPassword())) { result.rejectValue("password", ErrorMessageKeys.MUST_BE_MINIMIUM_LENGTH); } if (result.hasErrors()) { ModelAndView mav = new ModelAndView("newUser"); if (suggestedUsername != null) { mav.addObject("suggestedUsername", suggestedUsername); } mav.addObject(BindingResult.MODEL_KEY_PREFIX + "user", result); return mav; } // send verification email SimpleMailMessage verificationMessage = new SimpleMailMessage(userTemplateMessage); verificationMessage.setTo(ul.getEmail()); String encryptedPassword = passwordUtils.encryptPassword(ul.getPassword(), true); verificationMessage.setSubject("Confirm e-mail address for GBIF Data Portal"); verificationMessage.setText("Please visit the following link to confirm your e-mail address:\n\n" + "http://" + request.getHeader("host") + request.getContextPath() + "/user/verification" + "?fn=" + ul.getFirstName() + "&sn=" + ul.getSurname() + "&e=" + ul.getEmail() + "&u=" + ul.getUsername() + "&p=" + encryptedPassword); try { mailSender.send(verificationMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); ModelAndView mav = new ModelAndView("registrationVerificationFailureView"); mav.addObject("user", ul); return mav; } // successful ModelAndView mav = new ModelAndView("registrationVerificationSuccessView"); mav.addObject("user", ul); return mav; }
From source file:org.gbif.portal.web.controller.registration.RegistrationController.java
/** * This will send an email for approval to portal@gbif.org to ask if someone can see a providers details * //from w w w . j a v a2 s . c o m * @param request * @param response * @return * @throws Exception */ public ModelAndView sendRegistrationLoginsRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("user"); if (StringUtils.isEmpty(user)) { user = request.getRemoteUser(); } UserLogin ul = ldapUtils.getUserLogin(user); String[] businessKeysToRemove = request.getParameterValues("businessKeyToRemove"); List<String> existingKeys = uddiUtils.getAssociatedBusinessKeys(user); // remove the selected registration logins if (businessKeysToRemove != null) { for (String element : businessKeysToRemove) { if (existingKeys.contains(element)) uddiUtils.deleteRegistrationLogin(user, element); } } // send approval email String[] businessKeys = request.getParameterValues(REQUEST_BUSINESS_UDDI_KEY); // if not businesskeys selected, non requested return to menu if (businessKeys == null) { return new ModelAndView(new RedirectView(request.getContextPath() + "/register/")); } // send verification email SimpleMailMessage verificationMessage = new SimpleMailMessage(userTemplateMessage); verificationMessage.setTo(adminEmail); verificationMessage.setSubject("User has requested access to Provider Details"); StringBuffer sb = new StringBuffer("Please click here to review request:\n\n"); sb.append("http://"); sb.append(request.getHeader("host")); sb.append(request.getContextPath()); sb.append("/register/reviewUserRequest"); sb.append("?u=" + user); for (String businessKey : businessKeys) { sb.append("&r="); sb.append(businessKey); } verificationMessage.setText(sb.toString()); try { mailSender.send(verificationMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); ModelAndView mav = new ModelAndView("emailDetailsFailureView"); return mav; } // request sent view ModelAndView mav = new ModelAndView("requestSentView"); mav.addObject("userLogin", ul); return mav; }
From source file:org.gbif.portal.web.controller.registration.RegistrationController.java
/** * Update registration logins, creating those for the business keys passed in the request. * /*w w w . j a v a 2 s. c om*/ * @param request * @param response * @return * @throws Exception */ public ModelAndView updateRegistrationLogins(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("user"); boolean sendEmail = ServletRequestUtils.getBooleanParameter(request, "sendEmail", false); // if user is not supplied in a parameter, update is for the current user if (StringUtils.isEmpty(user)) { user = request.getRemoteUser(); } String[] businessKeys = request.getParameterValues(REQUEST_BUSINESS_UDDI_KEY); String[] businessKeysToRemove = request.getParameterValues("businessKeyToRemove"); List<String> existingKeys = uddiUtils.getAssociatedBusinessKeys(user); List<String> createdRegistrations = new ArrayList<String>(); // add the selected registration logins if (businessKeys != null) { for (int i = 0; i < businessKeys.length; i++) { if (!existingKeys.contains(businessKeys[i])) { uddiUtils.createRegistrationLogin(user, businessKeys[i]); createdRegistrations.add(businessKeys[i]); } } } // if required sent a notification email if (sendEmail && !createdRegistrations.isEmpty()) { UserLogin userLogin = ldapUtils.getUserLogin(user); // send verification email SimpleMailMessage verificationMessage = new SimpleMailMessage(userTemplateMessage); verificationMessage.setTo(userLogin.getEmail()); verificationMessage.setSubject("User has been granted access to Provider Details"); StringBuffer sb = new StringBuffer( "Your request to access the details of the following providers has been granted:\n\n"); for (String createdRegistration : createdRegistrations) { ProviderDetail pd = uddiUtils.createProviderFromUDDI(createdRegistration, userLogin.getUsername()); sb.append(pd.getBusinessName()); sb.append("\n"); } verificationMessage.setText(sb.toString()); try { mailSender.send(verificationMessage); } catch (MailException e) { // simply log it and go on... logger.error("Couldn't send message", e); } } // remove the selected registration logins if (businessKeysToRemove != null) { for (String element : businessKeysToRemove) { if (existingKeys.contains(element)) uddiUtils.deleteRegistrationLogin(user, element); } } return new ModelAndView(new RedirectView(request.getContextPath() + "/register/")); }
From source file:org.medici.bia.service.mail.MailServiceImpl.java
/** * //from ww w . j av a 2 s.c o m */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) @Override public Boolean sendActivationMail(ActivationUser activationUser) { try { if (!StringUtils.isBlank(activationUser.getUser().getMail())) { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(getMailFrom()); message.setTo(activationUser.getUser().getMail()); message.setSubject( ApplicationPropertyManager.getApplicationProperty("mail.activationUser.subject")); message.setText(ApplicationPropertyManager.getApplicationProperty("mail.activationUser.text", new String[] { activationUser.getUser().getFirstName(), activationUser.getUser().getAccount(), URLEncoder.encode(activationUser.getUuid().toString(), "UTF-8"), ApplicationPropertyManager.getApplicationProperty("website.protocol"), ApplicationPropertyManager.getApplicationProperty("website.domain"), ApplicationPropertyManager.getApplicationProperty("website.contextPath") }, "{", "}")); getJavaMailSender().send(message); activationUser.setMailSended(Boolean.TRUE); activationUser.setMailSendedDate(new Date()); getActivationUserDAO().merge(activationUser); } else { logger.error("Mail activation user not sended for user " + activationUser.getUser().getAccount() + ". Check mail field on tblUser for account " + activationUser.getUser().getAccount()); } return Boolean.TRUE; } catch (Throwable throwable) { logger.error(throwable); return Boolean.FALSE; } }
From source file:org.medici.bia.service.mail.MailServiceImpl.java
/** * {@inheritDoc}//w w w . ja va2 s .c o m */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) @Override public Boolean sendApprovedMail(ApprovationUser approvationUser) { try { if (!StringUtils.isBlank(approvationUser.getUser().getMail())) { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(getMailFrom()); message.setTo(approvationUser.getUser().getMail()); message.setSubject(ApplicationPropertyManager.getApplicationProperty("mail.approvedUser.subject")); message.setText(ApplicationPropertyManager.getApplicationProperty("mail.approvedUser.text", new String[] { approvationUser.getUser().getFirstName(), ApplicationPropertyManager.getApplicationProperty("website.protocol"), ApplicationPropertyManager.getApplicationProperty("website.domain"), ApplicationPropertyManager.getApplicationProperty("website.contextPath"), approvationUser.getUser().getAccount() }, "{", "}")); getJavaMailSender().send(message); approvationUser.setMailSended(Boolean.TRUE); approvationUser.setMailSendedDate(new Date()); getApprovationUserDAO().merge(approvationUser); } else { logger.error("Mail approved not sended for user " + approvationUser.getUser().getAccount() + ". Check mail field on tblUser for account " + approvationUser.getUser().getAccount()); } return Boolean.TRUE; } catch (Throwable throwable) { logger.error(throwable); return Boolean.FALSE; } }
From source file:org.medici.bia.service.mail.MailServiceImpl.java
/** * {@inheritDoc}//w w w. j a va 2 s .com */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) @Override public Boolean sendForumPostReplyNotificationMail(ForumPostNotified forumPostReplied, ForumPost forumPost, User currentUser) { try { if (!StringUtils.isBlank(currentUser.getMail())) { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(getMailFrom()); message.setTo(currentUser.getMail()); if (!Forum.SubType.COURSE.equals(forumPost.getForum().getSubType())) { // message for a reply post message.setSubject(ApplicationPropertyManager .getApplicationProperty("mail.forumPostReplyNotification.subject", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getParentPost().getSubject() }, "{", "}")); message.setText(ApplicationPropertyManager.getApplicationProperty( "mail.forumPostReplyNotification.text", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getParentPost().getSubject(), getForumTopicUrl(forumPost.getTopic(), Forum.SubType.COURSE.equals(forumPost.getForum().getSubType())) }, "{", "}")); } else { // message for a course transcription post or a course question post message.setSubject(ApplicationPropertyManager .getApplicationProperty("mail.courseTranscriptionNotification.subject", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getTopic().getSubject() }, "{", "}")); CourseTopicOption courseTopicOption = getCourseTopicOptionDAO() .getOption(forumPost.getTopic().getTopicId()); message.setText(ApplicationPropertyManager.getApplicationProperty( "mail.courseTranscriptionNotification.text", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getTopic().getSubject(), getCourseTopicUrl(courseTopicOption) }, "{", "}")); } getJavaMailSender().send(message); } else { logger.error("Mail for ForumPost reply not sended for user " + currentUser.getAccount() + ". Check mail field on tblUser for account " + currentUser.getAccount()); } forumPostReplied.setMailSended(Boolean.TRUE); forumPostReplied.setMailSendedDate(new Date()); return Boolean.TRUE; } catch (Throwable throwable) { logger.error(throwable); return Boolean.FALSE; } }
From source file:org.medici.bia.service.mail.MailServiceImpl.java
/** * {@inheritDoc}/* ww w . j a v a 2 s . com*/ */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) @Override public Boolean sendForumPostReplyNotificationMessage(ForumPostNotified forumPostReplied, ForumPost forumPost, User currentUser) { try { if (!StringUtils.isBlank(currentUser.getMail())) { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(getMailFrom()); message.setTo(currentUser.getMail()); if (!Forum.SubType.COURSE.equals(forumPost.getForum().getSubType())) { // message for a reply post message.setSubject(ApplicationPropertyManager .getApplicationProperty("mail.forumPostReplyNotification.subject", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getParentPost().getSubject() }, "{", "}")); message.setText(ApplicationPropertyManager.getApplicationProperty( "mail.forumPostReplyNotification.text", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getParentPost().getSubject(), getForumTopicUrl(forumPost.getTopic(), Forum.SubType.COURSE.equals(forumPost.getForum().getSubType())) }, "{", "}")); } else { // message for a course transcription post or a course question post message.setSubject(ApplicationPropertyManager .getApplicationProperty("mail.courseTranscriptionNotification.subject", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getTopic().getSubject() }, "{", "}")); CourseTopicOption courseTopicOption = getCourseTopicOptionDAO() .getOption(forumPost.getTopic().getTopicId()); message.setText(ApplicationPropertyManager.getApplicationProperty( "mail.courseTranscriptionNotification.text", new String[] { forumPost.getUser().getFirstName(), forumPost.getUser().getLastName(), forumPost.getTopic().getSubject(), getCourseTopicUrl(courseTopicOption) }, "{", "}")); } //getJavaMailSender().send(message); //instead of sending the message by email sending it by internal message // Composing Message UserMessage userMessage = new UserMessage(); userMessage.setSender("Staff"); User tempUser = currentUser; userMessage.setRecipient(tempUser.getAccount()); userMessage.setSubject(message.getSubject()); userMessage.setBody(message.getText()); userMessage.setMessageId(null); userMessage.setRecipientStatus(RecipientStatus.NOT_READ); userMessage.setSendedDate(new Date()); //Sending Message getCommunityService().createNewMessage(userMessage); } else { logger.error("Mail for ForumPost reply not sended for user " + currentUser.getAccount() + ". Check mail field on tblUser for account " + currentUser.getAccount()); } forumPostReplied.setMailSended(Boolean.TRUE); forumPostReplied.setMailSendedDate(new Date()); return Boolean.TRUE; } catch (Throwable throwable) { logger.error(throwable); return Boolean.FALSE; } }