Esempio n. 1
0
func (this *MailWriter) WriteMessage(level int, file string, line int, prefix string, msg string) {
	if level < this.level {
		return
	}

	if this.config == nil {
		return
	}

	if len(this.to) == 0 {
		return
	}

	var message = fmt.Sprintf("%s %s [%s:%d] %s", time.Now().String(), prefix, file, line, msg)

	var subject = this.GetSubject()
	if len(subject) == 0 {
		subject = file
	}

	var mail = email.NewTextMessage(subject, message)
	mail.To = this.to
	if len(this.from) > 0 {
		mail.From = this.from
	}

	go email.SendMail(this.config, mail)
}
Esempio n. 2
0
func (this *MailWriter) WriteMessage(level int, file string, line int, prefix string, msg string) {
	if level < this.level {
		return
	}

	if this.config == nil {
		return
	}

	if len(this.to) == 0 {
		return
	}

	var message = fmt.Sprintf("%s %s [%s:%d] %s", time.Now().String(), prefix, file, line, msg)
	var mail = email.NewTextMessage(file, message)
	mail.To = this.to

	go email.SendMail(this.config, mail)
}