@Bean
 public SimpleMailMessage citibankCreditCardPromotionMailMessage() {
   SimpleMailMessage mailMessage = new SimpleMailMessage();
   mailMessage.setFrom(mailForm);
   mailMessage.setTo(mailCitibankCreditCardPromotionTo);
   mailMessage.setReplyTo(mailReplyTo);
   mailMessage.setSubject(mailCitibankCreditCardPromotionSubject);
   return mailMessage;
 }
  private void send(String subject, String content) {
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setTo(supportEmail);
    mailMessage.setReplyTo(supportEmail);
    mailMessage.setFrom(supportEmail);
    mailMessage.setSubject(subject);
    mailMessage.setText(content);

    try {
      // javaMailSender.send(mailMessage);
    } catch (MailException e) {
      e.printStackTrace();
    }
  }
示例#3
0
 @Override
 public void sendTextMail(final MailMetaData mailMetaData, final String text) {
   if (suppressMail) {
     return;
   }
   final SimpleMailMessage mailMessage = new SimpleMailMessage();
   mailMessage.setFrom(
       new StringBuilder()
           .append(mailMetaData.getFromName())
           .append(" <")
           .append(mailMetaData.getFromAddress())
           .append(">")
           .toString());
   mailMessage.setSubject(mailMetaData.getSubject());
   mailMessage.setReplyTo(mailMetaData.getReplyTo());
   if (mailMetaData.getCcAddresses() != null && mailMetaData.getCcAddresses().size() > 0) {
     mailMessage.setCc(
         (String[])
             mailMetaData
                 .getCcAddresses()
                 .toArray(new String[mailMetaData.getCcAddresses().size()]));
   }
   if (mailMetaData.getBccAddresses() != null && mailMetaData.getBccAddresses().size() > 0) {
     mailMessage.setBcc(
         (String[])
             mailMetaData
                 .getBccAddresses()
                 .toArray(new String[mailMetaData.getBccAddresses().size()]));
   }
   if (mailMetaData.getToAddresses() != null && mailMetaData.getToAddresses().size() > 0) {
     mailMessage.setTo(
         (String[])
             mailMetaData
                 .getToAddresses()
                 .toArray(new String[mailMetaData.getToAddresses().size()]));
   }
   mailMessage.setText(text);
   try {
     mailSender.send(mailMessage);
   } catch (MailException e) {
     throw new SendMailException(
         new StringBuilder()
             .append("Error sending mail: ")
             .append(mailMetaData.toString())
             .toString(),
         e);
   }
 }
  public void emailPubs(ContactService.FeedbackRequest cue) {

    boolean hasEmail = cue.getEmail() != null && !"".equals(cue.getEmail());
    String userEmail = (hasEmail) ? cue.getEmail() : "";

    try {
      // FROM ADDRESS:
      InternetAddress addressFrom =
          (hasEmail) ? new InternetAddress(userEmail) : DEFAULT_REPLY_TO_ADDRESS;

      SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
      if (hasEmail) {
        msg.setReplyTo(userEmail);
      }

      StringBuilder sb = new StringBuilder();
      if (hasEmail) {
        sb.append("A NGWMN user with email address ")
            .append(userEmail)
            .append(" sends some feedback.\n");
      } else {
        sb.append(
            "A NGWMN user who does not care to provide their email address sends this feedback.\n");
      }
      if (cue.getEmailResponseRequired()) {
        sb.append("A response is requested, to email: ").append(userEmail).append("\n");
      }
      sb.append("\n\n");
      sb.append("Comment:\n");
      sb.append(cue.getComments());
      msg.setText(sb.toString());

      mailSender.send(msg);

      logger.info("Email sent to Remedy");
    } catch (MessagingException e) {
      logger.error("Error emailing Remedy.", e);
    }
  }