List of usage examples for org.springframework.mail SimpleMailMessage SimpleMailMessage
public SimpleMailMessage()
From source file:org.tsm.concharto.lab.LabJavaMail.java
private void sendConfirmationEmail(User user) { //mailSender.setHost("skipper"); SimpleMailMessage message = new SimpleMailMessage(); message.setTo(user.getEmail());//from www. j a v a 2 s .co m String messageText = StringUtils.replace(WELCOME_MESSAGE, PARAM_NAME, user.getUsername()); message.setText(messageText); message.setSubject(WELCOME_SUBJECT); message.setFrom("<Concharto Notifications> notify@concharto.com"); JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); MimeMessage mimeMessage = mailSender.createMimeMessage(); InternetAddress from = new InternetAddress(); from.setAddress("notify@concharto.com"); InternetAddress to = new InternetAddress(); to.setAddress(user.getEmail()); try { from.setPersonal("Concharto Notifications"); mimeMessage.addRecipient(Message.RecipientType.TO, to); mimeMessage.setSubject(WELCOME_SUBJECT); mimeMessage.setText(messageText); mimeMessage.setFrom(from); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } mailSender.setHost("localhost"); mailSender.send(mimeMessage); /* Confirm your registration with Concharto Hello sanmi, Welcome to the Concharto community! Please click on this link to confirm your registration: http://www.concharto.com/member/confirm.htm?id=:confirmation You can find out more about us at http://wiki.concharto.com/wiki/About. If you were not expecting this email, just ignore it, no further action is required to terminate the request. */ }
From source file:com.gnizr.web.action.user.TestApproveUserAccount.java
protected void setUp() throws Exception { super.setUp(); mailSender = new JavaMailSenderImpl(); mailSender.setHost("localhost"); gnizrConfiguration = new GnizrConfiguration(); gnizrConfiguration.setSiteContactEmail("admin@mysite.com"); gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr"); FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory(); factory.setTemplateLoaderPath("/templates"); freemarkerEngine = factory.createConfiguration(); welcomeMessage = new SimpleMailMessage(); welcomeMessage.setSubject("Welcome"); userManager = new UserManager(getGnizrDao()); tokenManager = new TokenManager(); tokenManager.setUserManager(userManager); tokenManager.init();/*from w w w . j a va2 s . c o m*/ action = new ApproveUserAccount(); action.setUserManager(userManager); action.setTokenManager(tokenManager); action.setGnizrConfiguration(gnizrConfiguration); action.setWelcomeEmailTemplate(welcomeMessage); action.setFreemarkerEngine(freemarkerEngine); action.setMailSender(mailSender); username = "hchen1"; token = tokenManager.createResetToken(new User(username)); }
From source file:ar.com.zauber.commons.message.impl.mail.SimpleEmailNotificationStrategy.java
/** @see NotificationStrategy#execute(NotificationAddress[], Message) */ //CHECKSTYLE:ALL:OFF public void execute(final NotificationAddress[] addresses, final Message message) { final SimpleMailMessage mail = new SimpleMailMessage(); mail.setFrom(getFromAddress().getEmailStr()); mail.setTo(getEmailAddresses(addresses)); mail.setReplyTo(getEmailAddress(message.getReplyToAddress())); mail.setSubject(message.getSubject()); mail.setText(message.getContent());/* w w w .j a v a 2 s . c o m*/ mailSender.send(mail); }
From source file:com.gnizr.web.action.user.TestRequestPasswordReset.java
protected void setUp() throws Exception { super.setUp(); gnizrConfiguration = new GnizrConfiguration(); gnizrConfiguration.setSiteContactEmail("admin@mysite.com"); gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr"); FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory(); factory.setTemplateLoaderPath("/templates"); freemarkerEngine = factory.createConfiguration(); userManager = new UserManager(getGnizrDao()); tokenManager = new TokenManager(); tokenManager.setUserManager(userManager); tokenManager.init();//from w w w. ja v a 2 s.co m templateMessage = new SimpleMailMessage(); templateMessage.setSubject("Reset Password"); mailSender = new JavaMailSenderImpl(); mailSender.setHost("localhost"); action = new RequestPasswordReset(); action.setUserManager(userManager); action.setTokenManager(tokenManager); action.setVerifyResetTemplate(templateMessage); action.setMailSender(mailSender); action.setFreemarkerEngine(freemarkerEngine); action.setGnizrConfiguration(gnizrConfiguration); }
From source file:de.codecentric.boot.admin.notify.MailNotifier.java
@Override protected void doNotify(ClientApplicationStatusChangedEvent event) { EvaluationContext context = new StandardEvaluationContext(event); SimpleMailMessage message = new SimpleMailMessage(); message.setTo(to);//from ww w. j a va 2 s. c o m message.setFrom(from); message.setSubject(subject.getValue(context, String.class)); message.setText(text.getValue(context, String.class)); message.setCc(cc); sender.send(message); }
From source file:nl.han.dare2date.service.notifier.UserNotifier.java
public void notify(Registration registration) { if (registration == null) { throw new IllegalArgumentException(); }/*from w w w . j av a2 s . c o m*/ User user = registration.getUser(); StringBuffer sbText = new StringBuffer(); sbText.append(String.format("Hoi %s", user.getFirstname())); sbText.append("\n\n"); sbText.append("Welkom bij Dare2Date."); sbText.append("\n\n"); sbText.append("Hierbij bevestigen wij uw registratie bij Dare2Date."); sbText.append("\n\n"); sbText.append("Met vriendelijke groet,"); sbText.append("\n\n"); sbText.append("Het Dare2Date Team"); SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(user.getEmail()); mail.setFrom(fromEmail); mail.setSubject("Je registratie bij Dare2Date"); mail.setText(sbText.toString()); mailSender.send(mail); }
From source file:org.homiefund.test.config.IntegrationConfiguration.java
@Bean(name = "templateMessage") public SimpleMailMessage simpleMailMessage() { SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setFrom("demo@localhost"); simpleMailMessage.setSubject("Invitiation to homiefund"); return simpleMailMessage; }
From source file:org.smigo.user.MailHandler.java
public void sendAdminNotification(String subject, Object text) { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(notifierEmail); simpleMailMessage.setFrom(mailSenderUsername); simpleMailMessage.setSubject("[SMIGO] " + subject); simpleMailMessage.setText(text.toString()); senderExecutor.execute(() -> mailSender.send(simpleMailMessage)); }
From source file:net.maritimecloud.identityregistry.utils.EmailUtil.java
public void sendOrgAwaitingApprovalEmail(String sendTo, String orgName) throws MailException { if (sendTo == null || sendTo.trim().isEmpty()) { throw new IllegalArgumentException("No email address!"); }/* w ww .java2 s. c o m*/ SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(sendTo); msg.setFrom(from); msg.setSubject(String.format(orgAwaitingApprovalSubject, orgName)); msg.setText(String.format(orgAwaitingApprovalText, orgName)); this.mailSender.send(msg); }
From source file:org.openregistry.core.service.DefaultEmailIdentifierNotificationStrategy.java
public void notifyPerson(Person person, Role role, Type addressType, Identifier idToNotifyAbout, String activationKeyString) throws IllegalArgumentException, IllegalStateException { if (person == null) { throw new IllegalArgumentException("Person must be specified"); }//from w w w . j ava 2 s .c om if (idToNotifyAbout == null) { throw new IllegalArgumentException("Identifier must be specified"); } Name officialName = person.getOfficialName(); SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(findEmailAddressesForNotification(person, role, addressType)); msg.setFrom(messageSource.getMessage("activation.notify.from", null, null)); msg.setSubject(messageSource.getMessage("activation.notify.subject", null, null)); String greeting = (officialName == null) ? "" : officialName.getFormattedName(); msg.setText(messageSource.getMessage("activation.notify.body", new String[] { greeting, idToNotifyAbout.getValue(), activationKeyString }, null)); mailSender.send(msg); }