示例#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/>
© 享链 2012
	</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 项目: yonglehou/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
}