当前位置: 首页>>代码示例>>Java>>正文


Java MimeMessageHelper.setReplyTo方法代码示例

本文整理汇总了Java中org.springframework.mail.javamail.MimeMessageHelper.setReplyTo方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMessageHelper.setReplyTo方法的具体用法?Java MimeMessageHelper.setReplyTo怎么用?Java MimeMessageHelper.setReplyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mail.javamail.MimeMessageHelper的用法示例。


在下文中一共展示了MimeMessageHelper.setReplyTo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMailWithTemplate

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:26,代码来源:MailServiceImpl.java

示例2: sendMailWithTemplate

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:24,代码来源:MailServiceImpl.java

示例3: sendContactNotification

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendContactNotification(final ContactForm contactForm) {
      MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @SuppressWarnings({ "rawtypes", "unchecked" })
		public void prepare(MimeMessage mimeMessage) throws Exception {
             MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
             message.setTo(configService.getValue("EMAIL_TO_CONTACT_MESSAGE"));
             message.setBcc("[email protected]");
             message.setFrom(new InternetAddress(contactForm.getEmail()));
             message.setSubject("New contact message " + contactForm.getTopic());
             message.setReplyTo(contactForm.getEmail());
             message.setSentDate(new Date());
             Map model = new HashMap();	             
             model.put("newMessage", contactForm);
             
             String text = VelocityEngineUtils.mergeTemplateIntoString(
                velocityEngine, "velocity/newContactMessageToAdmin.vm", "UTF-8", model);
             message.setText(text, true);
          }
       };
       this.mailSender.send(preparator);	  
}
 
开发者ID:PodcastpediaOrg,项目名称:podcastpedia-web,代码行数:22,代码来源:EmailNotificationServiceImpl.java

示例4: sendVerificationEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private EmailServiceTokenModel sendVerificationEmail(final EmailServiceTokenModel emailVerificationModel, final String emailSubject,
                                                     final String velocityModel, final Map<String, String> resources) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, MimeMessageHelper.MULTIPART_MODE_RELATED, "UTF-8");
            messageHelper.setTo(emailVerificationModel.getEmailAddress());
            messageHelper.setFrom(emailFromAddress);
            messageHelper.setReplyTo(emailReplyToAddress);
            messageHelper.setSubject(emailSubject);
            Map model = new HashMap();
            model.put("model", emailVerificationModel);
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityModel, model);
            messageHelper.setText(new String(text.getBytes(), "UTF-8"), true);
                  for(String resourceIdentifier: resources.keySet()) {
               addInlineResource(messageHelper, resources.get(resourceIdentifier), resourceIdentifier);
            }
        }
    };
    LOG.debug("Sending {} token to : {}",emailVerificationModel.getTokenType().toString(), emailVerificationModel.getEmailAddress());
    this.mailSender.send(preparator);
    return emailVerificationModel;
}
 
开发者ID:iainporter,项目名称:oauth2-provider,代码行数:23,代码来源:MailSenderServiceImpl.java

示例5: prepare

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void prepare(MimeMessage mimeMessage)
        throws MessagingException, UnsupportedEncodingException {
    MimeMessageHelper message = new MimeMessageHelper(mimeMessage, ENCODING);
    // set some headers to avoid automatic OutOfOffice replies
    mimeMessage.setHeader("Precedence", "list");
    mimeMessage.setHeader("X-Auto-Response-Suppress", "OOF");
    String identifier = mailMessage.getMessageIdentifier();
    if (identifier != null) {
        mimeMessage.setHeader(HEADER_MESSAGE_ID,
                MailMessageHelper.createMessageIdHeaderValue(identifier));
    }
    // set before as default, the velocity engine may overwrite this
    message.setFrom(mailMessage.getFromAddress(), mailMessage.getFromAddressName());
    message.setSentDate(new Date());

    String replyTo = mailMessage.getReplyToAddress();
    String replyToName = mailMessage.getReplyToAddressName();
    if (!StringUtils.isBlank(replyTo)) {
        message.setReplyTo(replyTo, replyToName);
    }

    // get global model
    Map<String, Object> model = mailMessage.getGlobalModel();
    mailMessage.prepareModel(model);
    model.put(MailModelPlaceholderConstants.MESSAGE, message);

    String text = renderVelocityTemplate(mailMessage.getContentTemplateId(),
            mailMessage.getContentTemplate(), model);
    message.setText(text, mailMessage.isHtmlMail());
    String subject = renderVelocityTemplate(mailMessage.getSubjectTemplateId(),
            mailMessage.getSubjectTemplate(), model);
    message.setSubject(subject);
    setRecipients(message);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:36,代码来源:VelocityMimeMessagePreparator.java

示例6: sendHtmlMessage

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendHtmlMessage(String from, String to, String subject, String text)
		throws MessagingException {
	MimeMessage message = this.mailSender.createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setFrom(this.defaultSender);
	helper.setTo(to);
	helper.setReplyTo(from);
	helper.setText(text, true);
	helper.setSubject(subject);

	this.mailSender.send(message);
}
 
开发者ID:ralscha,项目名称:eds-starter6-jpa,代码行数:14,代码来源:MailService.java

示例7: prepare

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void prepare(MimeMessage mimeMessage) throws MessagingException {
  MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage,
      true,
      Charsets.UTF_8.toString());
  try {
    messageHelper.setFrom(message.getFrom(), message.getFromName());
  } catch (UnsupportedEncodingException e) {
    throw new MessagingException(
        "UnsupportedEncodingException while encode 'the name of FROM person'",
        e);
  }
  messageHelper.setTo(message.getTo());

  if (message.getBcc() != null) {
    messageHelper.setBcc(message.getBcc());
  }

  if (message.getCc() != null) {
    messageHelper.setCc(message.getCc());
  }

  if (message.getReplyTo() != null) {
    messageHelper.setReplyTo(message.getReplyTo());
  }

  messageHelper.setSubject(message.getSubject());
  messageHelper.setText(message.getText());
}
 
开发者ID:kaif-open,项目名称:kaif,代码行数:29,代码来源:JavaMailAgent.java

示例8: sendMailWithAttachments

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendMailWithAttachments(final TemplateWithAttachmentMailTO template) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true);

            message.addTo(template.getToMailAddress());
            message.setFrom(template.getFromMailAddress());
            message.setSubject(template.getSubject());
            if (template.hasCcMailAddress()) {
                message.setCc(template.getCcMailAddress());
            }
            if (template.hasReplyTo()) {
                message.setReplyTo(template.getReplyTo());
            }

            // add attachments if any
            List<File> attachments = template.getAttachments();
            for (File file : attachments) {
                message.addAttachment(file.getName(), file);
            }

            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, template.getTemplateLocation(), template.getTemplateProperties());
            message.setText(text, true);
            message.setValidateAddresses(true);
        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:31,代码来源:MailServiceImpl.java

示例9: send

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public static void send(EmailHelper emailHelper, JavaMailSender javaMailSender) throws MessagingException {
    MimeMessage message = javaMailSender.createMimeMessage();

    MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");

    helper.setTo(emailHelper.to);
    helper.setFrom(emailHelper.from); //to avoid spam filters
    helper.setReplyTo(emailHelper.replyTo);
    helper.setSubject(emailHelper.subject);
    helper.setText(emailHelper.text, emailHelper.html);

    javaMailSender.send(message);

}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:15,代码来源:EmailSender.java

示例10: send

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void send(Event event, String to, List<String> cc, String subject, String text,
                 Optional<String> html, Attachment... attachments) {
    MimeMessagePreparator preparator = (mimeMessage) -> {
        MimeMessageHelper message = html.isPresent() || !ArrayUtils.isEmpty(attachments) ? new MimeMessageHelper(mimeMessage, true, "UTF-8")
                : new MimeMessageHelper(mimeMessage, "UTF-8");
        message.setSubject(subject);
        message.setFrom(configurationManager.getRequiredValue(Configuration.from(event.getOrganizationId(), event.getId(), SMTP_FROM_EMAIL)), event.getDisplayName());
        String replyTo = configurationManager.getStringConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), MAIL_REPLY_TO), "");
        if(StringUtils.isNotBlank(replyTo)) {
            message.setReplyTo(replyTo);
        }
        message.setTo(to);
        if(cc != null && !cc.isEmpty()){
            message.setCc(cc.toArray(new String[cc.size()]));
        }
        if (html.isPresent()) {
            message.setText(text, html.get());
        } else {
            message.setText(text, false);
        }

        if (attachments != null) {
            for (Attachment a : attachments) {
                message.addAttachment(a.getFilename(), new ByteArrayResource(a.getSource()), a.getContentType());
            }
        }
        
        message.getMimeMessage().saveChanges();
        message.getMimeMessage().removeHeader("Message-ID");
    };
    toMailSender(event).send(preparator);
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:34,代码来源:SmtpMailer.java

示例11: sendMimeMail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
/**
 *
 * Sends a MimeMessage.
 *
 * @param from The mail sender address.
 * @param replyTo The reply to address.
 * @param to A list of mail recipient addresses.
 * @param cc A list of carbon copy mail recipient addresses.
 * @param bcc A list of blind carbon copy mail recipient addresses.
 * @param subject The mail subject.
 * @param msg The mail message text.
 * @param html Whether to apply content type "text/html" or the default
 *             content type ("text/plain").
 * @param attachmentFilename The attachment file name.
 * @param attachmentFile The file resource to be applied to the mail.
 * @throws MessagingException 
 * @throws Exception 
 */
public void sendMimeMail(String from, String replyTo, String[] to, String[] cc,
		String[] bcc, String subject, String msg, Boolean html,
		String attachmentFilename, File attachmentFile)
				throws MessagingException, MailException {

	Boolean multipart = false;

	// if a attachment file is required, we have to use a multipart massage
	if (attachmentFilename!= null && attachmentFile != null) {
		multipart = true;
	}

	MimeMessage mimeMailMessage = mailSender.createMimeMessage();
	MimeMessageHelper mimeHelper = new MimeMessageHelper(mimeMailMessage,
			multipart);

	// fallback to default mail sender
	if (from == null || from.isEmpty()) {
		from = defaultMailSender;
	}

	// set minimal configuration
	mimeHelper.setFrom(from);
	mimeHelper.setTo(to);
	mimeHelper.setSubject(subject);
	mimeHelper.setText(msg, html);

	// add replyTo address if set
	if (replyTo != null && !replyTo.isEmpty()) {
		mimeHelper.setReplyTo(replyTo);
	}

	// add bcc address(es) if set
	if (bcc != null && bcc.length > 0) {
		mimeHelper.setBcc(bcc);
	}

	// add cc address(es) if set
	if (cc != null && cc.length > 0) {
		mimeHelper.setCc(cc);
	}

	// add attachment file if set
	if (attachmentFilename!= null && attachmentFile != null) {
		mimeHelper.addAttachment(attachmentFilename, attachmentFile);
	}

	sendMail(mimeMailMessage);
}
 
开发者ID:terrestris,项目名称:shogun2,代码行数:68,代码来源:MailPublisher.java

示例12: send

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public boolean send(final EmailAddress from, final EmailAddress replyTo, final EmailContent content,
    final EmailAddress to, final EmailAddress... tos) {

    List<EmailAddress> emailTos = new ArrayList<EmailAddress>();
    emailTos.add(to);

    if (is.notEmpty(tos)) {
        emailTos.addAll(Arrays.asList(tos));
    }

    final List<InternetAddress> addressesTo = new Converter().list(emailTos,
        new Convertable<EmailAddress, InternetAddress>() {
            @Override
            public InternetAddress convert(EmailAddress in) {
                try {
                    return new InternetAddress(in.getAddress(), in.getName());
                } catch (UnsupportedEncodingException e) {
                    log.error("Error creating InternetAddress:" + e, e);
                    throw new IllegalArgumentException("Error creating InternetAddress", e);
                }
            }
        });

    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage);
            helper.setTo(addressesTo.toArray(new InternetAddress[addressesTo.size()]));
            helper.setSubject(content.getSubject());
            helper.setFrom(from.getAddress(), from.getName());
            helper.setSentDate(new Date());
            helper.setReplyTo(replyTo.getAddress(), replyTo.getName());
            helper.setText(content.getHtmlContent(), true);
        }
    };
    // é usado um try catch para poder continuar com o processo mesmo que o
    // email gere um erro
    try {
        log.info("Sending email to:" + emailTos);
        mailSender.send(preparator);
        return true;
    } catch (Exception ex) {
        log.error("Error sending email to:" + emailTos, ex);
        return false;
    }
}
 
开发者ID:celiosilva,项目名称:csa,代码行数:47,代码来源:EmailManagerImpl.java

示例13: send

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void send() {
    try {
        String[] sa = {};
        MimeMessage message = mailer.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(message, charset);
        if (!recipients.isEmpty()) helper.setTo(recipients.toArray(sa));
        if (!ccs.isEmpty()) helper.setCc(ccs.toArray(sa));
        if (!bccs.isEmpty()) helper.setBcc(bccs.toArray(sa));
        if (S.notEmpty(from)) helper.setFrom(from);
        if (S.notEmpty(replyTo)) helper.setReplyTo(replyTo);

        helper.setSubject(subject);
        boolean u = underscoreImplicitVarNames;
        HttpServletRequest request = SessionManager.request();
        if (null != request) {
            // so this is running from a http request handling thread
            C.Map<String, Object> params = renderArgs;
            params.put(u ? "_request" : "request", request);
            params.put("__request", request);
            params.put(u ? "_response" : "response", SessionManager.response());
            HttpSession httpSession = request.getSession(false);
            params.put(u ? "_httpSession" : "httpSession", httpSession);
            if (enableSessionManager) {
                params.put(u ? "_session" : "session", Session.current());
                params.put(u ? "_flash" : "flash", Flash.current());
            }
            if (enableUserAgentDetector) {
                params.put(u ? "_userAgent" : "userAgent", UADetector.get());
            }
        }

        if (S.notEmpty(html)) {
            html = engine().render(html, renderArgs);
            helper.setText(html, true);
        }
        if (S.notEmpty(text)) {
            text = engine.render(text, renderArgs);
            helper.setText(text, false);
        }
        mailer.send(message);
    } catch (Exception e) {
        logger.error(e, "Error sending email");
    } finally {
        info.remove();
    }
}
 
开发者ID:rythmengine,项目名称:spring-rythm,代码行数:47,代码来源:MailerBase.java


注:本文中的org.springframework.mail.javamail.MimeMessageHelper.setReplyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。