List of usage examples for org.springframework.mail SimpleMailMessage setSubject
@Override public void setSubject(String subject)
From source file:me.j360.base.service.common.SimpleMailService.java
public void send(Email email) { SimpleMailMessage msg = new SimpleMailMessage(); msg.setFrom("?<system@smart-sales.cn>"); msg.setTo(email.getAccount());/*from w w w. j a v a 2 s .c o m*/ msg.setSubject(email.getSubject()); msg.setText(email.getBody()); try { mailSender.send(msg); /*if (logger.isInfoEnabled()) { logger.info("??{}", StringUtils.join(msg.getTo(), ",")); }*/ } catch (Exception e) { //logger.error("??", e); } }
From source file:com.springsource.greenhouse.reset.ResetPasswordMailMessageConverter.java
public SimpleMailMessage convert(ResetPasswordRequest request) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setFrom("Greenhouse <noreply@springsource.com>"); mailMessage.setTo(request.getAccount().getEmail()); StringTemplate textTemplate;//w ww . ja v a 2s . c o m mailMessage.setSubject("Reset your Greenhouse password"); textTemplate = resetTemplateFactory.getStringTemplate(); textTemplate.put("firstName", request.getAccount().getFirstName()); textTemplate.put("resetUrl", resetUriTemplate.expand(request.getToken())); mailMessage.setText(textTemplate.render()); return mailMessage; }
From source file:cz.muni.fi.mir.services.MailServiceImpl.java
@Override public void sendMail(String subject, String message) throws IllegalArgumentException { if (isEnabled()) { if (StringUtils.isEmpty(message)) { throw new IllegalArgumentException("Mail message (text) cannot be empty"); }/* w w w . ja va 2 s. c o m*/ SimpleMailMessage mess = new SimpleMailMessage(); mess.setFrom(sender); mess.setTo(sender); if (subjectPrefix != null) { mess.setSubject(subjectPrefix + subject); } else { mess.setSubject(subject); } mess.setText(message); mailSender.send(mess); } }
From source file:com.edgenius.wiki.gwt.server.HelperControllerImpl.java
public boolean sendNotify(String receiver, String text) { SimpleMailMessage msg = new SimpleMailMessage(); msg.setSubject(messageService.getMessage("sent.msg.title")); if (receiver == null) { if (!StringUtils.isBlank(Global.DefaultReceiverMail)) msg.setTo(Global.DefaultReceiverMail); if (Global.ccToSystemAdmin || StringUtils.isBlank(Global.DefaultReceiverMail)) { Set<String> bcc = userReadingService.getSystemAdminMailList(); if (bcc != null && bcc.size() > 0) msg.setBcc(bcc.toArray(new String[bcc.size()])); }//w ww . jav a 2 s.co m } else { //TODO: send message to special user - receiver is userID or email address? } msg.setFrom(Global.DefaultNotifyMail); msg.setText(text + "\r\n" + messageService.getMessage("sent.by") + " " + WikiUtil.getUser().getFullname()); mailService.send(msg); return true; }
From source file:com.miserablemind.butter.domain.service.email.EmailService.java
/** * Sends a plain text message. Uses {@link EmailMessage#getPlainTextBody()} * * @param emailMessage prepared message object to be sent. Usually prepared by {@link EmailManager} */// w ww .jav a 2s. co m public void sendTextMail(EmailMessage emailMessage) { SimpleMailMessage textMessage = new SimpleMailMessage(); textMessage.setFrom(emailMessage.getFromAddress().getAddress()); textMessage.setTo(emailMessage.getToEmail()); textMessage.setSubject(emailMessage.getSubject()); textMessage.setText(emailMessage.getPlainTextBody()); try { this.mailSender.send(textMessage); } catch (MailException e) { logger.error("Email Service Exception Send Text Mail: " + e.getMessage(), e); } }
From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java
/** * Send an error email of a not valid day report. * //from w w w .j ava2 s.com * @see org.springframework.mail.SimpleMailMessage * @see org.springframework.mail.javamail.JavaMailSenderImpl * @param dayReport I used DayReport as a parameter to know whom to send */ public void sendError(DayReport dayReport) { SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(dayReport.getPersonId()); msg.setReplyTo(dayReport.getPersonId()); msg.setFrom(user); msg.setSubject("RE: " + (dayReport.getSubject() == null ? "" : dayReport.getSubject())); msg.setText("This is an automated email. Do not reply.\n" + "No valid reports were detected. Check your report.\nExample of valid reports:\n" + "helping Google with Android, in process, 7\nmain job/ in process/1\nnothing actually. done. 3\n"); try { this.mailSender.send(msg); } catch (MailException ex) { logger.error(ex.getMessage()); } }
From source file:me.j360.base.service.common.SimpleMailService.java
/** * ??.//from ww w . j av a 2s. co m */ public void sendNotificationMail(String userName) { SimpleMailMessage msg = new SimpleMailMessage(); msg.setFrom("?<system@smart-sales.cn>"); msg.setTo("xuminwlt2008@163.com"); msg.setSubject("?"); //id String url = "http://www.smart-sales.cn/smartsales/com/email.action?keyId=1"; // ???? String content = String.format(textTemplate, userName, new Date(), url); msg.setText(content); /*try { mailSender.send(msg); if (logger.isInfoEnabled()) { logger.info("??{}", StringUtils.join(msg.getTo(), ",")); } } catch (Exception e) { logger.error("??", e); }*/ }
From source file:org.openxdata.server.servlet.ResetPasswordServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(this.getServletContext()); mailSender = (org.springframework.mail.javamail.JavaMailSenderImpl) ctx.getBean("mailSender"); userService = (UserService) ctx.getBean("userService"); userDetailsService = (UserDetailsService) ctx.getBean("userDetailsService"); messageSource = (ResourceBundleMessageSource) ctx.getBean("messageSource"); userLocale = new Locale((String) request.getSession().getAttribute("locale")); //new AcceptHeaderLocaleResolver().resolveLocale(request); log.debug("userLocale=" + userLocale.getLanguage()); String email = request.getParameter("email"); if (email == null) { //ajax response reference text out.println("noEmailSuppliedError"); }/*from w w w . j a va 2s.c o m*/ try { User user = userService.findUserByEmail(email); /* * Valid User with the correct e-mail. */ insertUserInSecurityContext(user); // this is so that it is possible to reset their password (security checks) Properties props = propertyPlaceholder.getResolvedProps(); String from = props.getProperty("mailSender.from"); try { //Reset the User password and send an email userService.resetPassword(user, 6); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(email); msg.setSubject(messageSource.getMessage("resetPasswordEmailSubject", new Object[] { user.getFullName() }, userLocale)); msg.setText(messageSource.getMessage("resetPasswordEmail", new Object[] { user.getName(), user.getClearTextPassword() }, userLocale)); msg.setFrom(from); try { mailSender.send(msg); //ajax response reference text out.println("passwordResetSuccessful"); } catch (MailException ex) { log.error("Error while sending an email to the user " + user.getName() + " in order to reset their password.", ex); log.error("Password reset email:" + msg.toString()); //ajax response reference text out.println("emailSendError"); } } catch (Exception e) { log.error("Error while resetting the user " + user.getName() + "'s password", e); //ajax response reference text out.println("passwordResetError"); } } catch (UserNotFoundException userNotFound) { /* * Invalid User or incorrect Email. */ //ajax response reference text out.println("validationError"); } }
From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java
/** * Send a confirmation email of a valid day report. * Includes xml readable string of it.// www . jav a 2s. c o m * @see org.springframework.mail.SimpleMailMessage * @see org.springframework.mail.javamail.JavaMailSenderImpl */ @Override public void placeReply(Reply reply) throws Exception { SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(reply.getEmailAddress()); msg.setReplyTo(reply.getEmailAddress()); msg.setFrom(user); msg.setSubject("RE: " + (reply.getSubject() == null ? "" : reply.getSubject())); msg.setText("This is an automated email. Do not reply.\n" + "Your day report is recieved and saved ." + " You are allowed to make modifications till 23:59 GMT+3." + " Just send new report, the old one will be deleted.\n" + "Converted report look like:\n" + reply.getXml()); try { this.mailSender.send(msg); } catch (MailException ex) { logger.error(ex.getMessage()); } }
From source file:org.smigo.user.MailHandler.java
public void sendClientMessage(String emailAddress, String subject, String text) { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(emailAddress); simpleMailMessage.setFrom(mailSenderUsername); simpleMailMessage.setSubject("Smigo " + subject); simpleMailMessage.setText(text);//from w w w. ja va 2 s .c om senderExecutor.execute(() -> mailSender.send(simpleMailMessage)); }