List of usage examples for org.springframework.mail SimpleMailMessage SimpleMailMessage
public SimpleMailMessage()
From source file:ubc.pavlab.aspiredb.server.controller.SignupController.java
/** * Send an email to request signup confirmation. * // w w w .j av a 2 s . co m * @param request * @param u */ private String sendResetConfirmationEmail(HttpServletRequest request, String token, String username, String password, String email) { String message = ""; // Send an account information e-mail SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setFrom(ConfigUtils.getAdminEmailAddress()); mailMessage.setSubject(getText("signup.email.subject", request.getLocale())); try { Map<String, Object> model = new HashMap<>(); model.put("username", username); model.put("password", password); model.put("confirmLink", ConfigUtils.getBaseUrl() + "confirmRegistration.html?key=" + token + "&username=" + username); model.put("message", getText("login.passwordReset.emailMessage", request.getLocale())); String templateName = "passwordReset.vm"; sendEmail(username, email, getText("login.passwordReset.emailSubject", request.getLocale()), templateName, model); message = getText("login.passwordReset", new Object[] { username, email }, request.getLocale()); saveMessage(request, message); } catch (Exception e) { message = "Couldn't send password change confirmation email to " + email; throw new RuntimeException(message, e); } return message; }
From source file:ubc.pavlab.aspiredb.server.service.ProjectServiceImpl.java
private void sendEmail(String username, String email, Map<String, Object> model) { String subject = this.messageUtil.getText("projectUpload.email.subject", Locale.getDefault()); String templateName = "projectUploaded.vm"; SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setFrom(ConfigUtils.getAdminEmailAddress()); mailMessage.setSubject(subject);/*from w w w .j a v a2 s . co m*/ mailMessage.setTo(username + "<" + email + ">"); mailEngine.sendMessage(mailMessage, templateName, model); }
From source file:ubc.pavlab.aspiredb.server.util.MailEngineImpl.java
/** * Sends a message to the gemma administrator as defined in the Gemma.properties file * /*from w ww.ja v a2 s.co m*/ * @param bodyText * @param subject */ @Override public void sendAdminMessage(String bodyText, String subject) { if ((bodyText == null) && (subject == null)) { log.warn("Not sending empty email, both subject and body are null"); return; } log.info("Sending email notification to administrator regarding: " + subject); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(ConfigUtils.getAdminEmailAddress()); msg.setFrom(ConfigUtils.getAdminEmailAddress()); msg.setSubject(subject); msg.setText(bodyText); this.send(msg); }
From source file:ubic.gemma.core.util.MailUtilsImpl.java
@Override public void sendTaskCompletedNotificationEmail(EmailNotificationContext emailNotificationContext, TaskResult taskResult) {/*from ww w . ja va 2 s .c om*/ String taskId = emailNotificationContext.getTaskId(); String submitter = emailNotificationContext.getSubmitter(); String taskName = emailNotificationContext.getTaskName(); if (StringUtils.isNotBlank(submitter)) { User user = userService.findByUserName(submitter); assert user != null; String emailAddress = user.getEmail(); if (emailAddress != null) { MailUtilsImpl.log.info("Sending email notification to " + emailAddress); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(emailAddress); msg.setFrom(Settings.getAdminEmailAddress()); msg.setSubject("Gemma task completed"); String logs = ""; if (taskResult.getException() != null) { logs += "Task failed with :\n"; logs += taskResult.getException().getMessage(); } msg.setText("A job you started on Gemma is completed (taskId=" + taskId + ", " + taskName + ")\n\n" + logs + "\n"); mailEngine.send(msg); } } }
From source file:ubic.gemma.persistence.service.TableMaintenanceUtilImpl.java
private void sendEmail(Gene2CsStatus results) { if (!sendEmail) return;//from ww w . jav a 2s.c o m SimpleMailMessage msg = new SimpleMailMessage(); String adminEmailAddress = Settings.getAdminEmailAddress(); if (StringUtils.isBlank(adminEmailAddress)) { TableMaintenanceUtilImpl.log.warn( "No administrator email address could be found, so gene2cs status email will not be sent."); return; } msg.setTo(adminEmailAddress); msg.setSubject("Gene2Cs update status."); msg.setText("Gene2Cs updating was run.\n" + results.getAnnotation()); mailEngine.send(msg); TableMaintenanceUtilImpl.log.info("Email notification sent to " + adminEmailAddress); }
From source file:ubic.gemma.persistence.util.MailEngineImpl.java
/** * Sends a message to the gemma administrator as defined in the Gemma.properties file *//*from w w w . ja va 2 s . c om*/ @Override public void sendAdminMessage(String bodyText, String subject) { if ((bodyText == null) && (subject == null)) { MailEngineImpl.log.warn("Not sending empty email, both subject and body are null"); return; } MailEngineImpl.log.info("Sending email notification to administrator regarding: " + subject); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(Settings.getAdminEmailAddress()); msg.setFrom(Settings.getAdminEmailAddress()); msg.setSubject(subject); msg.setText(bodyText); this.send(msg); }
From source file:ubic.gemma.util.MailUtilsImpl.java
@Override public void sendTaskCompletedNotificationEmail(EmailNotificationContext emailNotificationContext, TaskResult taskResult) {//from www .j a v a2 s.c o m String taskId = emailNotificationContext.getTaskId(); String submitter = emailNotificationContext.getSubmitter(); String taskName = emailNotificationContext.getTaskName(); if (StringUtils.isNotBlank(submitter)) { User user = userService.findByUserName(submitter); assert user != null; String emailAddress = user.getEmail(); if (emailAddress != null) { log.debug("Sending email notification to " + emailAddress); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(emailAddress); msg.setFrom(ConfigUtils.getAdminEmailAddress()); msg.setSubject("Gemma task completed"); String logs = ""; if (taskResult.getException() != null) { logs += "Task failed with :\n"; logs += taskResult.getException().getMessage(); } msg.setText("A job you started on Gemma is completed (taskid=" + taskId + ", " + taskName + ")\n\n" + logs + "\n"); /* * TODO provide a link to something relevant something like: */ // String url = ConfigUtils.getBaseUrl() + "user/tasks.html?taskId=" + taskId; mailEngine.send(msg); } } }
From source file:ubic.gemma.web.controller.BaseController.java
protected void sendConfirmationEmail(HttpServletRequest request, String token, String username, String email, Map<String, Object> model, String templateName) { try {/*from w ww .j a v a2s . c o m*/ model.put("username", username); model.put("confirmLink", Settings.getBaseUrl() + "confirmRegistration.html?key=" + token + "&username=" + username); SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setFrom(Settings.getAdminEmailAddress()); mailMessage.setSubject(getText("signup.email.subject", request.getLocale())); mailMessage.setTo(username + "<" + email + ">"); mailEngine.sendMessage(mailMessage, templateName, model); } catch (Exception e) { log.error("Couldn't send email to " + email, e); } }
From source file:ubic.gemma.web.controller.BaseFormController.java
/** * Convenience message to send messages to users */// w w w . j a v a2s . com protected void sendEmail(User user, String msg) { if (StringUtils.isBlank(user.getEmail())) { log.warn("Could not send email to " + user + ", no email address"); } log.debug("sending e-mail to user [" + user.getEmail() + "]..."); SimpleMailMessage message = new SimpleMailMessage(); message.setTo(user.getFullName() + "<" + user.getEmail() + ">"); mailEngine.send(message); }
From source file:ubic.gemma.web.controller.BaseFormController.java
/** * Convenience message to send messages to users *///from w ww . ja v a 2 s. com protected void sendEmail(User user, String templateName, Map<String, Object> model) { if (StringUtils.isBlank(user.getEmail())) { log.warn("Could not send email to " + user + ", no email address"); } SimpleMailMessage message = new SimpleMailMessage(); message.setTo(user.getFullName() + "<" + user.getEmail() + ">"); mailEngine.sendMessage(message, templateName, model); }