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


Java MailException类代码示例

本文整理汇总了Java中org.springframework.mail.MailException的典型用法代码示例。如果您正苦于以下问题:Java MailException类的具体用法?Java MailException怎么用?Java MailException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: send

import org.springframework.mail.MailException; //导入依赖的package包/类
@Override
public void send(MimeMessage mimeMessage) throws MailException {
	try {
		System.out.println("---- START OF EMAIL MESSAGE ----");
		System.out.println();

		mimeMessage.writeTo(System.out);

		System.out.println();
		System.out.println("----- END OF EMAIL MESSAGE -----");
	} catch (MessagingException | IOException e) {
		LOG.error("Error sending to console: {}", e.getMessage());
	}
}
 
开发者ID:mychalvlcek,项目名称:spring-rest-skeleton,代码行数:15,代码来源:ConsoleMailSender.java

示例2: sendAdminEmailOnRoleChange

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * 
 * Email Update on Role Change - Called when User Role is Changed
 * 
 * @param certDn DN of the certificate that is being updated
 * @param role New Role of Certificate
 * @param cert_key Key of the updated Certificate
 * @param userEmail E-mail address of local RA Manager / CA Manager
 */
public void sendAdminEmailOnRoleChange(String certDn, String role, long cert_key, String userEmail){
    log.debug("sendAdminEmailOnRoleChange method");
    StringBuilder emailDebug = new StringBuilder("Emailing new role [");
    emailDebug.append(role);
    // Create a thread safe "copy" of the template message and customize it 
    SimpleMailMessage msg = new SimpleMailMessage(this.emailTemplate);
    msg.setTo(userEmail);
    msg.setSubject("UK CA Role Updated");
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("cert_dn", certDn);
    vars.put("basePortalUrl", basePortalUrl);
    vars.put("req_key", cert_key); 
    vars.put("new_role", role);
    try {
        this.mailSender.send(msg, vars, this.emailAdminsRoleChangeTemplate);
    } catch (MailException ex) {
        log.error("MailSender " + ex.getMessage());
    }
    
    emailDebug.append("]");
    log.debug(emailDebug);
}
 
开发者ID:UKCA,项目名称:CAPortal,代码行数:32,代码来源:EmailService.java

示例3: sendMailWithTemplate

import org.springframework.mail.MailException; //导入依赖的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

示例4: sendFiestaEmail

import org.springframework.mail.MailException; //导入依赖的package包/类
@Override
public boolean sendFiestaEmail(FiestaPlayer fiestaPlayer, eMailMessage e_mail, String subject) {
    // creates a simple e-mail object
    mailMessage.setTo(fiestaPlayer.getEmail());
    mailMessage.setFrom("[email protected]");
    mailMessage.setSubject(subject);
    e_mail.setMessageForFiestaPlayer(fiestaPlayer);
    mailMessage.setText(e_mail.getMessage());

    // sends the e-mail

    try {
        mailSender.send(mailMessage);
        System.out.println(mailMessage.toString());
        System.out.println("Mail Sent to "+ fiestaPlayer.getEmail());
        fiestaPlayer.setMailStatus("Mail sent");
        return true;
    }
    catch (MailException ex) {
        // simply log it and go on...
        System.out.println("Mail not sent to "+ fiestaPlayer.getEmail());
        fiestaPlayer.setMailStatus("Mail not sent");
        System.err.println(ex.getMessage());
        return false;
    }
}
 
开发者ID:Recks11,项目名称:theLXGweb,代码行数:27,代码来源:sendNotificationImpl.java

示例5: sendMailAsBcc

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * 指定された宛先一覧に BCC で一括送信します。
 *
 * @param recipients 宛先一覧
 * @param subject    件名
 * @param text       本文
 */
@Async
public void sendMailAsBcc(List<String> recipients, String subject, String text) {
    if (recipients.isEmpty()) {
        throw new IllegalArgumentException("recipients is empty.");
    }
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(recipients.toArray(new String[recipients.size()]));
    message.setSubject(subject);
    message.setText(text);
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:24,代码来源:MailService.java

示例6: sendAttendMail

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * 登録完了メールを送信します。
 *
 * @param membership  メンバー情報
 * @param convocation 対象のイベント招待
 */
@Async
void sendAttendMail(Membership membership, Convocation convocation) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【登録完了】" + convocation.getSubject());
    message.setText(membership.getName() + " さん\n\n" +
            convocation.getSubject() + "の登録が完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:26,代码来源:MailService.java

示例7: sendCancelMail

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * キャンセル完了メールを送信します。
 *
 * @param membership  メンバー情報
 * @param convocation 対象のイベント招待
 */
@Async
void sendCancelMail(Membership membership, Convocation convocation) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【キャンセル完了】" + convocation.getSubject());
    message.setText(membership.getName() + " さん\n\n" +
            convocation.getSubject() + "の登録キャンセルが完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:26,代码来源:MailService.java

示例8: sendPasswordResetMail

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * パスワードリセット案内メールを送信します。
 *
 * @param request パスワードリセット要求
 */
@Async
void sendPasswordResetMail(PasswordResetRequest request) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setTo(request.getMembership().getEmail());
    message.setSubject("【パスワードリセット】Java研修 Go研修 OB・OG会");
    message.setText(request.getMembership().getName() + " さん\n\n" +
            "パスワードリセットの要求を受け付けました。\n" +
            "下記 URL から 24 時間以内にパスワードリセットを行ってください。\n\n" +
            appUrl + "/#!" + ResetPasswordView.VIEW_NAME + "/" + request.getToken() + "\n" +
            "※トップページにリダイレクトされてしまう場合は、トップページを開いた画面 (タブ) のアドレス欄に" +
            "上記 URL を張り付けて移動してください。\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:26,代码来源:MailService.java

示例9: sendUpdateMail

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * メンバー情報更新完了メールを送信します。
 *
 * @param membership メンバー情報
 */
@Async
void sendUpdateMail(Membership membership) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【会員情報編集完了】Java研修 Go研修 OB・OG会");
    message.setText(membership.getName() + " さん\n\n" +
            "会員情報の編集が完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:25,代码来源:MailService.java

示例10: sendEmail

import org.springframework.mail.MailException; //导入依赖的package包/类
/**
 * To send email.
 * 
 * @param mailParam its map containing mail headers details. i.e. "from"
 */  
public void sendEmail(EmailDTO emailDTO) {
	try { 
		if (Objects.nonNull(emailDTO)) {
			MimeMessage  mail = javaMailSenderImpl.createMimeMessage();
			MimeMessageHelper helper = new MimeMessageHelper(mail, true);
			helper.setSubject(emailDTO.getSubject());
			helper.setText(emailDTO.getMessage(), true);
			helper.setFrom(emailDTO.getFrom(), configurationService.getMailConfiguration().getFrom());
			helper.setTo(emailDTO.getTo());
			if (Objects.nonNull(emailDTO.getAttachment())) {
				helper.addAttachment(emailDTO.getAttachmentName(), emailDTO.getAttachment());
			}
			javaMailSenderImpl.send(mail);
		}
	} catch (MessagingException | MailException | UnsupportedEncodingException e) {
		logger.error("Exception while sending mail notification.", e);
	}
}
 
开发者ID:Zymr,项目名称:visitormanagement,代码行数:24,代码来源:EmailService.java

示例11: send

import org.springframework.mail.MailException; //导入依赖的package包/类
public void send(String fromEmail, String toEmail,String subject, String text) {
    LOG.info("Starting Send...");
    this.templateMessage = new SimpleMailMessage();
    this.templateMessage.setSubject(subject);
    this.templateMessage.setFrom(fromEmail);
    this.templateMessage.setTo(toEmail);

    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
    msg.setText(text);
    LOG.info(templateMessage.toString());
    try {
        this.mailSender.send(msg);
    } catch (MailException ex) {
        LOG.error(ex.getMessage());
    }
    LOG.info("Finished Send...");
}
 
开发者ID:asmodeirus,项目名称:BackOffice,代码行数:18,代码来源:MailModel.java

示例12: sendEmail

import org.springframework.mail.MailException; //导入依赖的package包/类
@Override
public boolean sendEmail(final List<String> emails, final String subject, final String body) {
	if (emails == null || emails.isEmpty()) {
		return false;
	}
	asyncExecute(new Runnable() {
		public void run() {
			MimeMessagePreparator preparator = new MimeMessagePreparator() {
				public void prepare(MimeMessage mimeMessage) throws Exception {
					MimeMessageHelper msg = new MimeMessageHelper(mimeMessage);
					msg.setTo(emails.toArray(new String[0]));
					msg.setSubject(subject);
					msg.setFrom(Config.SUPPORT_EMAIL);
					msg.setText(body, true); // body is assumed to be HTML
				}
			};
			try {
				mailSender.send(preparator);
				logger.debug("Email sent to {}, {}", emails, subject);
			} catch (MailException ex) {
				logger.error("Failed to send email. {}", ex.getMessage());
			}
		}
	});
	return true;
}
 
开发者ID:Erudika,项目名称:scoold,代码行数:27,代码来源:ScooldEmailer.java

示例13: send

import org.springframework.mail.MailException; //导入依赖的package包/类
@Async
public void send(@NotNull final EmailEntity entity) {
    final MimeMessage message = prepareMessage(entity);
    entity.setLastRetryTime(ZonedDateTime.now());
    entity.setRetryTimes(entity.getRetryTimes() + 1);
    try {
        javaMailSender.send(message);
        entity.setSent(true);
        entity.setErrorMessage(null);
        log.info("Email sent: from {}, to {}, subject {}", entity.getSender(), entity.getRecipients(), entity.getSubject());
    } catch (MailException e) {
        log.warn("{}", e);
        entity.setErrorMessage(e.getMessage());
    }
    emailRepository.save(entity);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:17,代码来源:AsyncMailSenderImpl.java

示例14: sendActivation

import org.springframework.mail.MailException; //导入依赖的package包/类
@Override
public void sendActivation(User user) throws InvalidTokenException {

    if (user.getActivationToken() == null) {
        throw new InvalidTokenException("No activation token found for " + user.toString());
    }

    Map<String, Object> model = getBaseModel(user);
    model.put("url", hostname + "#/activation/" + user.getUsername() + "/" + user.getActivationToken().getToken());

    final String body = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "templates/sendActivation.vm", "UTF-8", model);

    MimeMessagePreparator preparator = mimeMessage -> {
        mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail()));
        mimeMessage.setFrom(new InternetAddress(mailFromAddress));
        mimeMessage.setSubject("Kanbanboard WGM Accountaktivierung");
        mimeMessage.setText(body, "UTF-8", "html");
    };

    try {
        mailSender.send(preparator);
        log.info("Activation Mail sent to "+ user.getEmail());
    } catch (MailException e) {
        log.error("Could not send activation mail to " + user.getEmail() + ". The error was :", e);
    }
}
 
开发者ID:Morbrolhc,项目名称:kanbanboard,代码行数:27,代码来源:EMailServiceImpl.java

示例15: sendPasswordReset

import org.springframework.mail.MailException; //导入依赖的package包/类
@Override
public void sendPasswordReset(User user) throws InvalidTokenException {

    if (user.getPasswordResetToken() == null) {
        throw new InvalidTokenException("No password reset token found for " + user.toString());
    }

    final Map<String, Object> model = getBaseModel(user);
    model.put("url", hostname + "#/reset/" + user.getUsername() + "/" + user.getPasswordResetToken().getToken());

    final String body = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "templates/sendPasswordReset.vm", "UTF-8", model);

    MimeMessagePreparator preparator = mimeMessage -> {
        mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail()));
        mimeMessage.setFrom(new InternetAddress(mailFromAddress));
        mimeMessage.setSubject("Kanbanboard WGM Passwort Reset");
        mimeMessage.setText(body, "UTF-8", "html");
    };

    try {
        mailSender.send(preparator);
        log.info("Reset Mail sent to {}", user.getEmail());
    } catch (MailException e) {
        log.error("Could not send mail to " + user.getEmail() + ". The error was :", e);
    }
}
 
开发者ID:Morbrolhc,项目名称:kanbanboard,代码行数:27,代码来源:EMailServiceImpl.java


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