This commit is contained in:
parent
ce6d43f95d
commit
84db3a864e
2
pom.xml
2
pom.xml
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 + "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue