http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mail
# 添加依赖包
```
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.4</version>
</dependency>
```
# 编写java代码
```
public static void sendMail() {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setFrom("weichunhe@netfinworks.com");
msg.setTo("1329555958@qq.com");
msg.setText("hello test mail");
msg.setSubject("wch");
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost("smtp.exmail.qq.com");
sender.setPort(465);
sender.setUsername("weichunhe@netfinworks.com");
sender.setPassword("wid2");
Properties properties = new Properties();
properties.put("mail.smtp.ssl.enable", true);
// properties.put("mail.smtp.auth", "true");
// properties.put("mail.smtp.socketFactory.class",
// SSLSocketFactory.class.getName());
sender.setJavaMailProperties(properties);
sender.send(msg);
}
```