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


Java MailAuthenticationException类代码示例

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


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

示例1: sendMail

import org.springframework.mail.MailAuthenticationException; //导入依赖的package包/类
@Override
public void sendMail(String mailTo, String message) {

    LOGGER.debug(String.format("Sending mail to '%s' with message '%s'", mailTo, message));

    try {
        mailSender.send(initMimeMessage(message, mailTo));
        LOGGER.info("Sent mail to " + mailTo);
    } catch (MessagingException | MailAuthenticationException e) {
        LOGGER.warn("Sending confirmation code email failed", e);
    }
}
 
开发者ID:Yannic92,项目名称:shoppingList,代码行数:13,代码来源:MailServiceImpl.java

示例2: checkEmailConnection

import org.springframework.mail.MailAuthenticationException; //导入依赖的package包/类
/**
 * Tries to send a tets email to the passed testEmailAddress with using the passed subject and message.<br>
 * If sending succeeds then no exception will be thrown.
 * 
 * @param mailServerSettings The settings of the mail server on which it shall be tried to send the test mail
 * @param testEmailAddress
 * @param testSubject
 * @param testMessage
 * @throws MailServerConnectionFailedException Thrown when test email could not be sent
 */
public void checkEmailConnection(MailServerSettings mailServerSettings, String testEmailAddress, String testSubject, String testMessage)
		throws MailServerConnectionFailedException {
	MailSender customMailSender = createCustomMailSender(mailServerSettings);

	SimpleMailMessage mailMessage = new SimpleMailMessage();
	mailMessage.setSubject(testSubject);
	mailMessage.setTo(testEmailAddress);
	mailMessage.setText(testMessage);
	mailMessage.setFrom(mailServerSettings.getFrom());

	if (StringUtils.isNotEmpty(mailServerSettings.getReplyTo())) {
		mailMessage.setReplyTo(mailServerSettings.getReplyTo());
	}

	try {
		customMailSender.send(mailMessage);
	}
	catch (MailAuthenticationException authEx) {
		throw new MailServerConnectionFailedException(authEx).setMailConnectionError(MAIL_CONNECTION_ERROR.AUTHENTICATION);
	}
	catch (MailSendException sendEx) {
		throw new MailServerConnectionFailedException(sendEx).setMailConnectionError(MAIL_CONNECTION_ERROR.SEND);
	}
	catch (Exception ex) {
		throw new MailServerConnectionFailedException(ex).setMailConnectionError(MAIL_CONNECTION_ERROR.UNKNOWN);
	}
}
 
开发者ID:Clemens85,项目名称:runningdinner,代码行数:38,代码来源:EmailService.java

示例3: handleMail

import org.springframework.mail.MailAuthenticationException; //导入依赖的package包/类
@ExceptionHandler({ MailAuthenticationException.class })
public ResponseEntity<Object> handleMail(final RuntimeException ex, final WebRequest request) {
    logger.error("500 Status Code", ex);
    final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.email.config.error", null, request.getLocale()), "MailError");
    return new ResponseEntity<Object>(bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR);
}
 
开发者ID:Baeldung,项目名称:spring-security-registration,代码行数:7,代码来源:RestResponseEntityExceptionHandler.java


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