class SMTPServerConfiguration {

	@Bean
	public JavaMailSender getJavaMailSender() {
		JavaMailSenderImpl mailSender = createMailSender();
		mailSender.setHost(hostname);
		mailSender.setPort(hostPort);

		if (isNotEmpty(username)) {
			mailSender.setUsername(username);
		}
		if (isNotEmpty(password)) {
			mailSender.setPassword(password);
		}

		Properties props = mailSender.getJavaMailProperties();

		try {
			Map<String, String> map = configConverter.convertToMap(smtpConfigString);
			for (String key : map.keySet()) {
				props.put(key, map.get(key));
			}
		} catch (Exception e) {
			LOG.error("Was not able to apply given smtp configuration");
		}

		return mailSender;
	}

}