private JavaMailSender getMailSender ( ) { final JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl ( ) ; final ApplicationConfiguration smtpHostConfig = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_HOST , SMTP_HOST , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_HOST , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_HOST , "localhost" ) ; final ApplicationConfiguration smtpPort = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_PORT , SMTP_PORT , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_PORT , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_PORT , DEFAULT_SMTP_PORT ) ; final ApplicationConfiguration smtpUsername = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_USERNAME , SMTP_USERNAME , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_USERNAME , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_USERNAME , "username" ) ; final ApplicationConfiguration smtpPassword = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_SECRET , SMTP_SECRET , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_SECRET , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_SECRET , "password" ) ; final ApplicationConfiguration smtpAuth = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_AUTH , SMTP_AUTH , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_AUTH , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_AUTH , "true" ) ; final ApplicationConfiguration smtpStartTlsEnable = applicationConfigurationService . checkValueOrLoadDefault ( EMAIL_CONFIGURATION_SMTP_STARTTLS_ENABLE , SMTP_STARTTLS_ENABLE , ConfigurationGroup . EXTERNAL_SERVICES , EmailServiceImpl . class . getSimpleName ( ) , SMTP_STARTTLS_ENABLE , RESPONSIBLE_FOR_SENDING_EMAIL , APPLICATION_EMAIL_SMTP_STARTTLS_ENABLE , "true" ) ; javaMailSender . setHost ( smtpHostConfig . getPropertyValue ( ) ) ; javaMailSender . setPort ( getSmtpPort ( smtpPort ) ) ; javaMailSender . setUsername ( smtpUsername . getPropertyValue ( ) ) ; javaMailSender . setPassword ( smtpPassword . getPropertyValue ( ) ) ; final Properties javaMailProperties = new Properties ( ) ; javaMailProperties . setProperty ( MAIL_SMTP_AUTH , smtpAuth . getPropertyValue ( ) ) ; javaMailProperties . setProperty ( MAIL_SMTP_STARTTLS_ENABLE , smtpStartTlsEnable . getPropertyValue ( ) ) ; javaMailSender . setJavaMailProperties ( javaMailProperties ) ; return javaMailSender ; }
Gets the mail sender .