Package org.springframework.mail

Examples of org.springframework.mail.SimpleMailMessage


        assertSendOperation(msg);
    }

    @Test
    public void testSendSimpleMessageArray() throws Exception {
        SimpleMailMessage msg = createSimpleMailMessage("testSendSimpleMessageArray", "from@a", "to@a", "cc@a", "bcc@a", "replyTo@a");
        sender.send(new SimpleMailMessage[]{msg});
        assertSendOperation(msg);
    }
View Full Code Here


        assertEquals(type + ": orphan addresses - " + addrSet, 0, addrSet.size());
        return op;
    }

    static SimpleMailMessage createSimpleMailMessage(String subject, String from, String to, String cc, String bcc, String replyTo) {
        SimpleMailMessage msg = new SimpleMailMessage();
        msg.setFrom(from);
        msg.setSubject(subject);
        msg.setSentDate(new Date());
        msg.setTo(to);
        msg.setCc(cc);
        msg.setBcc(bcc);
        msg.setReplyTo(replyTo);
        msg.setText("Blah");
        return msg;
    }
View Full Code Here

      mav.addObject("error",
          "Sorry, we could not find a user with your email address. Please try again.");
      mav.addObject("release", env.get("release"));
      return mav;
    }
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(email);

        // Retrieve postmark properties.  Keys postmarkApiKey and postmarkSendAddress should be set
        // in common.properties
        String postmarkSendAddress = env.get("postmarkSendAddress");
        String postmarkApiKey = env.get("postmarkApiKey");

        // Process postmarkSendAddress
        if(postmarkSendAddress==null) {
            postmarkSendAddress = "support@fluxtream.com";
            logger.warn("component=support_controller action=sendResetRequest" +
                                    " guestId=" + guest.getId() +
                                    " message=\"**** PLEASE SET postmarkSendAddress IN common.properties; defaulting to support@fluxtream.com\"");
        }
    message.setFrom(postmarkSendAddress);

        // Process postmarkApiKey
        if(postmarkApiKey==null) {
            logger.error("component=support_controller action=sendResetRequest" +
                                    " guestId=" + guest.getId() +
                                    " message=\"**** PLEASE SET postmarkApiKey IN common.properties.  Cannot send reset email without it.\"");
            ModelAndView mav = new ModelAndView("support/serverConfigError");
            mav.addObject("release", env.get("release"));
            mav.addObject("userMessage", "We are not able to send email for resetting your password");
            mav.addObject("adminMessage", "Please set up the following keys in common.properties to enable email sending: postmarkApiKey and postmarkSendAddress");
            return mav;
        }
        PostmarkMailSender sender = new PostmarkMailSender(
              env.get("postmarkApiKey"));



    message.setSubject("Fluxtream Reset password request");
    Map<String, String> vars = new HashMap<String, String>();
    ResetPasswordToken pToken = guestService.createToken(guest.getId());
    vars.put("token", pToken.token);
    vars.put("homeBaseUrl", env.get("homeBaseUrl"));
    if (guest.firstname != null && !guest.firstname.equals(""))
      vars.put("username", guest.firstname);
    else
      vars.put("username", guest.username);
        String mailMessage ="Hi " + vars.get("username") + ",\n" +
                            "\n" +
                            "Someone requested that your Fluxtream password be reset.\n" +
                            "\n" +
                            "If this wasn't you, there's nothing to worry about - simply ignore this email and nothing will change.\n" +
                            "\n" +
                            "If you DID ask to reset the password on your Fluxtream account, just click here to make it happen:\n" +
                            "\n" +
                            vars.get("homeBaseUrl") + "support/resetPassword?token=" + vars.get("token") + "\n" +
                            "\n" +
                            "Thanks,\n" +
                            "\n" +
                            "The Fluxtream Team";

    message.setText(mailMessage);
    sender.send(message);
    ModelAndView mav = new ModelAndView("support/resetRequestSent");
    mav.addObject("release", env.get("release"));
    return mav;
  }
View Full Code Here

  @Autowired
  private JavaMailSenderImpl mailSender;
 
  public void sendMail(String from, String to, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(msg);
    mailSender.send(message)
  }
View Full Code Here

    mailSender.send(message)
  }
 
  public void sendMail(String from, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(env.getProperty("support.email"));
    message.setTo(env.getProperty("support.email"));
    message.setSubject(subject);
    message.setText(msg+"\n\nThanks,\n"+from);
    mailSender.send(message)
  }
View Full Code Here

  @Autowired
  private JavaMailSenderImpl mailSender;
 
  public void sendMail(String from, String to, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(msg);
    mailSender.send(message)
  }
View Full Code Here

    mailSender.send(message)
  }
 
  public void sendMail(String from, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(env.getProperty("support.email"));
    message.setTo(env.getProperty("support.email"));
    message.setSubject(subject);
    message.setText(msg+"\n\nThanks,\n"+from);
    mailSender.send(message)
  }
View Full Code Here

    this.mailSender = mailSender;
  }

  @Async
  public void send(final ResetPasswordRequest request) {
    SimpleMailMessage mail = converter.convert(request);
    mailSender.send(mail);
  }
View Full Code Here

  public ResetPasswordMailMessageConverter(@Value("#{environment['application.secureUrl']}/reset?token={token}") String resetUriTemplate) {
    this.resetUriTemplate = new UriTemplate(resetUriTemplate);
  }
 
  public SimpleMailMessage convert(ResetPasswordRequest request) {
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setFrom("Greenhouse <noreply@springsource.com>");
    mailMessage.setTo(request.getAccount().getEmail());
    StringTemplate textTemplate;
    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;
  }
View Full Code Here

  @Test
  public void welcomeMail() {
    WelcomeMailTransformer transformer = new WelcomeMailTransformer();

    Account account = new Account(1L, "Roy", "Clarkson", "rclarkson@vmware.com", "rclarkson", "http://foo.com/bar.jpg", new UriTemplate("http://greenhouse.springsource.org/members/{id}"));
    SimpleMailMessage welcomeMail = (SimpleMailMessage) transformer.welcomeMail(account);

    assertEquals("rclarkson@vmware.com", welcomeMail.getTo()[0]);
    assertEquals("Greenhouse <noreply@springsource.com>", welcomeMail.getFrom());
    assertEquals("Welcome to the Greenhouse!", welcomeMail.getSubject());
    String mailText = welcomeMail.getText();
    assertTrue(mailText.contains("View your member profile at:" + NEWLINE + "http://greenhouse.springsource.org/members/rclarkson"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.mail.SimpleMailMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.