赞
踩
1.添加邮件发送需要的pom依赖
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>javax.mail-api</artifactId>
- <version>1.5.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-email</artifactId>
- <version>1.4</version>
- </dependency>
2.邮件发送工具类
- /**
- * 发送邮件的方法
- * @param host :邮件服务器地址
- * @param account :账户(发送方)
- * @param password :账户密码(发送方)
- * @param port :邮箱服务器端口(发送方)
- * @param toUser :收件人
- * @param title :标题
- * @param content :内容
- */
-
- public static void sendMail(String host, String account, String password, String port, String toUser, String title, String content) throws Exception {
- Properties props = System.getProperties();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。