Exemplo n.º 1
0
func (c *UserController) CreateRegisterCaptcha() {
	mail := c.GetString("mail")
	sessionId := c.CruSession.SessionID()
	var captcha string
	mailCaptchaKey := strings.Replace(constants.MAIL_CAPTCHA_KEY, "$sessionId", sessionId, 1)
	redis_util.Get(mailCaptchaKey, &captcha)
	beego.Debug("captcha", captcha)
	if len(captcha) == 0 {
		captcha = utils.RandomIntCaptcha(6)
		redis_util.Set(mailCaptchaKey, captcha, 60*2)
	}
	content := fmt.Sprintf(services.MAIL_CAPTCHA_TEMPLATE, captcha, captcha)
	services.SendHtmlMail("threeperson(www.threeperson.com)注册验证码", content, []string{mail})
	c.JsonSuccess(60)

}
func TestSendHtmlMail(t *testing.T) {

	content := fmt.Sprintf(services.MAIL_CAPTCHA_TEMPLATE, "11111", "22222")

	services.SendHtmlMail("邮件测试", content, []string{"*****@*****.**"})
}