當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。