@Override
    public EmailCommunicationResult send(final EmailMessageRequest emailRequest) throws Exception {
        val mailSender = createMailSender(emailRequest);
        val connectionAvailable = mailSender != null && FunctionUtils.doAndHandle(() -> {
            mailSender.testConnection();
            return true;
        }, throwable -> false).get();

        val recipients = emailRequest.getRecipients();
        if (connectionAvailable) {
            val message = createEmailMessage(emailRequest, mailSender);
            emailSenderCustomizers.forEach(customizer -> customizer.customize(mailSender, emailRequest));
            mailSender.send(message);
        }

        return EmailCommunicationResult.builder()
            .success(connectionAvailable)
            .to(recipients)
            .body(emailRequest.getBody())
            .build();
    }
This is {@link DefaultEmailSender}.

@author Misagh Moayyed
@since 7.0.0
core/cas-server-core-notifications-api/src/main/java/org/apereo/cas/notifications/mail/DefaultEmailSender.java