예제 #1
0
func sendMail(email *models.EmailInvite) error {

	user := "******"
	password := "******"
	host := "smtp.163.com:25"
	to := email.ToEmail

	subject := fmt.Sprintf("%s 邀请你加入觅链", email.UserName)
	body := fmt.Sprintf(`
	<html>
	<body>
%s 邀请你加入觅链
<br/>
觅链(<a href="http://%s">%s</a>)是一个由大家共建的XXXXXXX社区,简介XXXXXXXXX。
<br/>
请点击以下链接完成注册:
<a href="http://%s/user/reg?key=%s">http://%s/user/reg?key=%s</a>
<br/>
© 觅链 2013
	</body>
	</html>
	`, email.UserName, golink.Host_Name, golink.Host_Name, golink.Host_Name, email.Guid, golink.Host_Name, email.Guid)

	err := utils.SendMail(user, password, host, to, subject, body, "html")
	return err
}
예제 #2
0
파일: user.go 프로젝트: cloudcache/ohlala
func user_recoveryPasswordBySendingEmail(u *User, ur *UserRecovery) (err error) {
	cfgTemplate := config.UserRecoveryConfig
	mailSender := cfgTemplate.MailSender
	query := url.Values{}
	query.Set("token", ur.Token)
	recoverLink := golink.Host_Name + "/user/" + strconv.FormatInt(u.Id, 10) + "/recover?" + query.Encode()
	mailBody := strings.Replace(cfgTemplate.MailContent.ContentTemplate, "$recoveryLink", recoverLink, -1)

	err = utils.SendMail(mailSender.From, mailSender.Password, mailSender.SmtpServer, u.Email, cfgTemplate.MailContent.SubjectTemplate, mailBody, "html")

	return
}