示例#1
0
// Send the link to email addresse
func (rcv *controller) sendLink(link string) error {

	if err := mail.Send(rcv.formUser.Email, link); err != nil {
		return err
	}
	return nil

}
示例#2
0
// After successfully signed up, it will send a confirmation
// email to user with the to activated link. Redis will keep
// this uri for 24 hours. If the user does not activated the
// account within this time, it will deleted from neo4j data-
// base and the user have to sign up again.
func (rcv *controller) sendActivationLink(email string) error {

	uri := uniuri.NewLen(20)
	expired := time.Now().Unix() + 86400
	con := redis.Get()
	_, err := con.Do("HMSET", uri, "email", email, "expired", expired)
	if err != nil {
		return err
	}

	// Will delete the link in 48 hours
	con.Do("EXPIREAT", uri, time.Now().Add(time.Hour*48).Unix())

	link := rcv.Request.Host + "/activate/" + uri
	if err = mail.Send(email, link); err != nil {
		return err
	}
	return nil
}