protected JavaMailSenderImpl applyProperties(final JavaMailSenderImpl sender,
                                                 final EmailMessageRequest emailRequest) {
        val effectiveProperties = findTenantEmailProperties(emailRequest);

        sender.setHost(effectiveProperties.getHost());
        if (effectiveProperties.getPort() != null) {
            sender.setPort(effectiveProperties.getPort());
        }
        sender.setUsername(effectiveProperties.getUsername());
        sender.setPassword(effectiveProperties.getPassword());

        sender.setProtocol(effectiveProperties.getProtocol());
        sender.setDefaultEncoding(effectiveProperties.getDefaultEncoding().name());

        val javaMailProperties = asProperties(effectiveProperties.getProperties());
        val protocol = StringUtils.defaultIfBlank(effectiveProperties.getProtocol(), "smtp");

        val ssl = effectiveProperties.getSsl();
        if (ssl.isEnabled()) {
            javaMailProperties.setProperty("mail." + protocol + ".ssl.enable", "true");
        }
        if (StringUtils.isNotBlank(ssl.getBundle())) {
            val sslBundle = sslBundles.getObject().getBundle(ssl.getBundle());
            val socketFactory = sslBundle.createSslContext().getSocketFactory();
            javaMailProperties.put("mail." + protocol + ".ssl.socketFactory", socketFactory);
        }
        if (!javaMailProperties.isEmpty()) {
            sender.setJavaMailProperties(javaMailProperties);
        }
        return sender;
    }
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