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


Java MimeMessageHelper.setFrom方法代码示例

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


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

示例1: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendEmail(final UserDTO user, String url) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(user.getEmail());
            message.setSubject(SUBJECT);
            message.setFrom(EMAIL_FROM); // could be parameterized...
            Map model = new HashMap();
            model.put("user", user);
            model.put("url", url);
            String text = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, "org/enricogiurin/sushibar/registration-confirmation.vm", model);
            message.setText(text, true);
        }
    };
    this.emailSender.send(preparator);
}
 
开发者ID:egch,项目名称:sushi-bar-BE,代码行数:19,代码来源:EmailSenderImpl.java

示例2: sendWithAttachment

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendWithAttachment(String to, String subject, String templateName, Map<String, String> data,
    InputStream attachment, String attachmentName) {

    LOG.debug("Sending email from {} to {} with subject {}", from, to, subject);

    MimeMessagePreparator messagePreparator = message -> {
        MimeMessageHelper helper = new MimeMessageHelper(message, true);
        helper.setTo(to);
        helper.setFrom(from);
        helper.setSubject(subject);
        helper.setText(templateService.createTemplate(templateName, data));
        helper.addAttachment(attachmentName, new ByteArrayResource(IOUtils.toByteArray(attachment)));
    };
    mailSender.send(messagePreparator);

    IOUtils.closeQuietly(attachment);
}
 
开发者ID:Contargo,项目名称:iris,代码行数:19,代码来源:SpringEmailService.java

示例3: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
        isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(jHipsterProperties.getMail().getFrom());
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent email to User '{}'", to);
    } catch (Exception e) {
        log.warn("Email could not be sent to user '{}'", to, e);
    }
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:20,代码来源:MailService.java

示例4: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendEmail(@NonNull final Mail _mail,
                      @NonNull final String _body,
                      @Nullable final String _attachmentFilename,
                      @Nullable final byte[] _pdfAttachment) {
    try {
        // Prepare message using a Spring helper
        final MimeMessage mimeMessage = mailSender.createMimeMessage();
        final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, (_pdfAttachment != null), StandardCharsets.UTF_8.name());
        message.setSubject("Tifoon Scan Report");
        message.setFrom(_mail.getSender());
        message.setTo(_mail.getRecipient());

        message.setText(_body, true);

        if (_attachmentFilename != null && _pdfAttachment != null) {
            message.addAttachment(_attachmentFilename, new ByteArrayResource(_pdfAttachment));
        }

        // Send mail
        mailSender.send(mimeMessage);
    } catch (MessagingException _e) {
        log.error("Failed to send e-mail", _e);
    }
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:26,代码来源:ReportEmailSenderServiceImpl.java

示例5: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
        isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(jHipsterProperties.getMail().getFrom());
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent email to User '{}'", to);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.warn("Email could not be sent to user '{}'", to, e);
        } else {
            log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
        }
    }
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:24,代码来源:MailService.java

示例6: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}", isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(mailFromDisplay);
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent email to User '{}'", to);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.warn("Email could not be sent to user '{}'", to, e);
        } else {
            log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
        }
    }
}
 
开发者ID:megadotnet,项目名称:SpringBootDemoApp,代码行数:23,代码来源:MailService.java

示例7: sendMail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendMail(SendMailActionMsg msg) throws MessagingException {
  log.debug("Sending mail {}", msg);
  MimeMessage mailMsg = mailSender.createMimeMessage();
  MimeMessageHelper helper = new MimeMessageHelper(mailMsg, "UTF-8");
  helper.setFrom(msg.getFrom());
  helper.setTo(msg.getTo());
  if (!StringUtils.isEmpty(msg.getCc())) {
    helper.setCc(msg.getCc());
  }
  if (!StringUtils.isEmpty(msg.getBcc())) {
    helper.setBcc(msg.getBcc());
  }
  helper.setSubject(msg.getSubject());
  helper.setText(msg.getBody());
  mailSender.send(helper.getMimeMessage());
  log.debug("Mail sent {}", msg);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:MailPlugin.java

示例8: prepareEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private int prepareEmail(MimeMessage mimeMessage, String subject, String emailAddresses) throws Exception {
	int toCount = 0;
	if (!CommonUtil.isEmptyString(emailAddresses)) {
		MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, false, EMAIL_ENCODING);
		mimeMessageHelper.setSubject(subject);
		mimeMessageHelper.setText(output.toString());
		mimeMessageHelper.setFrom(Settings.getEmailExecFromAddress(), Settings.getEmailExecFromName());
		String[] addresses = emailAddressSeparatorRegexp.split(emailAddresses, -1);
		for (int i = 0; i < addresses.length; i++) {
			if (!CommonUtil.isEmptyString(addresses[i])) {
				mimeMessageHelper.addTo(addresses[i].trim());
				toCount++;
			}
		}
	}
	return toCount;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:JobOutput.java

示例9: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
        isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(jHipsterProperties.getMail().getFrom());
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent e-mail to User '{}'", to);
    } catch (Exception e) {
        log.warn("E-mail could not be sent to user '{}'", to, e);
    }
}
 
开发者ID:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:20,代码来源:MailService.java

示例10: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
        isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(jHipsterProperties.getMailgun().getFrom());
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent e-mail to User '{}'", to);
    } catch (Exception e) {
        log.warn("E-mail could not be sent to user '{}', exception is: {}", to, e.getMessage());
    }
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:20,代码来源:MailService.java

示例11: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
    log.debug("Send e-mail[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
        isMultipart, isHtml, to, subject, content);

    // Prepare message using a Spring helper
    MimeMessage mimeMessage = javaMailSender.createMimeMessage();
    try {
        MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
        message.setTo(to);
        message.setFrom(jHipsterProperties.getMail().getFrom());
        message.setSubject(subject);
        message.setText(content, isHtml);
        javaMailSender.send(mimeMessage);
        log.debug("Sent e-mail to User '{}'", to);
    } catch (Exception e) {
        log.warn("E-mail could not be sent to user '{}', exception is: {}", to, e.getMessage());
    }
}
 
开发者ID:RawSanj,项目名称:blogAggr,代码行数:20,代码来源:MailService.java

示例12: sendHtmlEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public int sendHtmlEmail(String subject, String content, String to) {

        try {
            MimeMessage mimeMessage = mailSender.createMimeMessage();
            MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "utf-8");
            mimeMessage.setContent(content, "text/html;charset=utf-8");
            messageHelper.setFrom(mailMessage.getFrom());
            messageHelper.setSubject(subject); //主题
            messageHelper.setTo(to); //发送给
            messageHelper.setCc(mailMessage.getFrom()); //抄送

            mailSender.send(mimeMessage);    //发送邮件

        } catch (Exception e) {
            logger.error("the email send error ! content: {}, exception: {}", content, e);
            return -1;
        }finally {
        }
        return 1;
    }
 
开发者ID:shuaijunlan,项目名称:Autumn-Framework,代码行数:21,代码来源:WebEmail.java

示例13: alert

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void alert(BaseRule rule, String content) throws Exception {
    Config ruleConfig = rule.getConfig();
    List<String> recipients = ruleConfig.getStringList("alerter.email.recipients");

    String from = "";
    String subject = "";
    MimeMessage mimeMessage = mailSender.createMimeMessage();
    MimeMessageHelper mailMessage = new MimeMessageHelper(mimeMessage, false, "utf-8");

    mailMessage.setFrom(from);

    mailMessage.setTo(recipients.toArray(new String[recipients.size()]));
    mailMessage.setSubject(subject);
    mimeMessage.setContent(content, "text/html");
}
 
开发者ID:balamaci,项目名称:muninn,代码行数:17,代码来源:MailAlerter.java

示例14: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void sendEmail(final String to, final String subject, final String content, final boolean isMultipart,
		final boolean isHtml) {

	final MimeMessage mimeMessage = javaMailSender.createMimeMessage();
	try {
		final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, CharEncoding.UTF_8);
		message.setFrom(uaaProperties.getMail().getFrom());
		message.setTo(to);
		message.setSubject(subject);
		message.setText(content, isHtml);
		javaMailSender.send(mimeMessage);
		LOGGER.debug("Sent email to User '{}' with subject '{}'", to, subject);
	} catch (final MessagingException | MailException e) {
		LOGGER.warn("Mail could not be sent to user '{}'", to, e);
	}
}
 
开发者ID:JanLoebel,项目名称:uaa-service,代码行数:18,代码来源:EmailService.java

示例15: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
protected void sendEmail(String email, String authCode) throws MessagingException, UnsupportedEncodingException {
    MimeMessage mimeMessage = mMailSender.createMimeMessage();

    MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, "UTF-8");
    helper.setSubject("欢迎加入 LsPush 大家庭");
    helper.setFrom(serverEmail, serverName);
    helper.setTo(email);

    String authLink = String.format("%s/user/auth?auth_code=%s", serverUrl, authCode);
    final Context ctx = new Context(Locale.CHINA);
    ctx.setVariable("serverUrl", serverUrl);
    ctx.setVariable("serverName", serverName);
    ctx.setVariable("email", email);
    ctx.setVariable("authCode", authCode);
    ctx.setVariable("authLink", authLink);

    String html = mTemplateEngine.process("lspush_captcha_email", ctx);

    helper.setText(html, true);
    mMailSender.send(mimeMessage);
}
 
开发者ID:TomeOkin,项目名称:LsPush-Server,代码行数:22,代码来源:CaptchaService.java


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