Пример #1
0
Файл: base.go Проект: grr89/hrkb
func (c *BaseController) SendMails(html string) {
	var users []M.User

	err := DM.FindAll(&M.User{}, &users, M.Sf{}, M.Where{And: M.W{"NotifyByMail": true}})

	if err != nil {
		beego.Error("Find users error ", err)
	}

	mail := M.Mail{}
	mail.ToType = "to"

	//Getting config data
	mail.FromMail = beego.AppConfig.String("mail::from_mail")
	mail.FromName = sql.NullString{beego.AppConfig.String("mail::from_name"), true}
	mail.Subject = sql.NullString{beego.AppConfig.String("mail::from_subject"), true}

	mail.Html = sql.NullString{html, true}
	mail.Text = sql.NullString{"", true}

	for _, user := range users {
		mail.ToName = sql.NullString{user.Name, true}
		mail.ToMail = user.Email
		//Send with Notification Service
		NFS.Send(mail)
	}
}
Пример #2
0
func newMail(id int) M.Mail {
	mail := M.Mail{}
	mail.Id = id
	mail.ToMail = "*****@*****.**"
	mail.ToName = sql.NullString{"Abdullo", true}
	mail.ToType = "to"
	mail.FromMail = "*****@*****.**"
	mail.FromName = sql.NullString{"hrkb", true}
	mail.Subject = sql.NullString{"notification", true}
	mail.Html = sql.NullString{"<h1>long interestin html</h1>", true}
	mail.Text = sql.NullString{"some text", true}
	return mail
}