List of usage examples for org.springframework.mail.javamail JavaMailSenderImpl DEFAULT_PORT
int DEFAULT_PORT
To view the source code for org.springframework.mail.javamail JavaMailSenderImpl DEFAULT_PORT.
Click Source Link
From source file:com.glaf.mail.config.JavaMailSenderConfiguration.java
@Bean(name = "javaMailSender") public JavaMailSenderImpl buildJavaMailSender() { MailConfig cfg = new MailConfig(); String filename = SystemProperties.getConfigRootPath() + Constants.MAIL_CONFIG; Properties properties = PropertiesUtils.loadFilePathResource(filename); cfg.setEncoding(properties.getProperty("mail.defaultEncoding", "GBK")); cfg.setHost(properties.getProperty("mail.host", "127.0.0.1")); cfg.setUsername(properties.getProperty("mail.username")); cfg.setPassword(properties.getProperty("mail.password")); if (StringUtils.equals(properties.getProperty("mail.auth"), "true")) { cfg.setAuth(true);/*from w w w. ja v a 2 s .com*/ } int port = JavaMailSenderImpl.DEFAULT_PORT; if (properties.getProperty("mail.port") != null) { port = Integer.parseInt(properties.getProperty("mail.port")); } JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setJavaMailProperties(properties); sender.setHost(properties.getProperty("mail.host")); sender.setPort(port); sender.setProtocol(JavaMailSenderImpl.DEFAULT_PROTOCOL); sender.setUsername(properties.getProperty("mail.username")); sender.setPassword(properties.getProperty("mail.password")); sender.setDefaultEncoding(properties.getProperty("mail.defaultEncoding", "GBK")); return sender; }