This commit is contained in:
谢洪龙 2017-07-21 14:35:42 +08:00
parent ce6d43f95d
commit 84db3a864e
3 changed files with 29 additions and 2 deletions

View File

@ -5,7 +5,7 @@
<artifactId>ifish</artifactId> <artifactId>ifish</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>ifish Maven Webapp</name> <name>ifish</name>
<url>http://mvnrepository.com</url> <url>http://mvnrepository.com</url>
<dependencies> <dependencies>

View File

@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;

View File

@ -197,4 +197,32 @@ public class Mail {
return true; return true;
} }
/**
* 发送邮箱验证码
*
* @param email
* @return
*/
public static String sendRegisterCode(String email) {
Mail theMail = new Mail(smtp);
if (!theMail.setSubject("邮箱注册验证码")) {
return "";
}
if (!theMail.setFrom(from)) {
return "";
}
if (!theMail.setTo(to)) {
return "";
}
Integer code = (int) (Math.random() * 9000 + 1000);
if (!theMail.setBody(code + "")) {
return "";
}
if (!theMail.sendOut()) {
return "";
}
return code + "";
}
} }