@Override
    public void afterPropertiesSet() throws Exception {
        mailSender.setHost(emailProperties.getEmailHost());

        if (!StringUtils.isEmpty(emailProperties.getEmailUser())) {
            mailSender.setUsername(emailProperties.getEmailUser());
        }

        if (!StringUtils.isEmpty(emailProperties.getEmailPassword())) {
            mailSender.setPassword(emailProperties.getEmailPassword());
        }

        if (!StringUtils.isEmpty(emailProperties.getEmailPort())) {

            try {

                Integer port = Integer.parseInt(emailProperties.getEmailPort());
                mailSender.setPort(port);
            } catch (Exception e) {
                LOG.error(e.toString());
            }
        }
    }
@ Override public void afterPropertiesSet ( ) throws Exception { mailSender . setHost ( emailProperties . getEmailHost ( ) ) ; if ( ! StringUtils . isEmpty ( emailProperties . getEmailUser ( ) ) ) { mailSender . setUsername ( emailProperties . getEmailUser ( ) ) ; } if ( ! StringUtils . isEmpty ( emailProperties . getEmailPassword ( ) ) ) { mailSender . setPassword ( emailProperties . getEmailPassword ( ) ) ; } if ( ! StringUtils . isEmpty ( emailProperties . getEmailPort ( ) ) ) { try { Integer port = Integer . parseInt ( emailProperties . getEmailPort ( ) ) ; mailSender . setPort ( port ) ; } catch ( Exception e ) { LOG . error ( e . toString ( ) ) ; } } }
设置邮箱host，用户名和密码