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
@@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
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.multipart.MultipartFile;
+28
View File
@@ -197,4 +197,32 @@ public class Mail {
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 + "";
}
}