コード例 #1
0
ファイル: send-invite-email.go プロジェクト: Leon1108/ohlala
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
}