You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
623 B
26 lines
623 B
3 years ago
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
import "net/smtp"
|
||
|
|
||
|
func (e Email) send() {
|
||
|
|
||
|
message := fmt.Sprintf("From: %s\n", config.MyEmail)
|
||
|
for _, recipient := range e.Recipients {
|
||
|
message += fmt.Sprintf("To: %s\n", recipient)
|
||
|
}
|
||
|
message += fmt.Sprintf("Subject: %s\n", e.Subject)
|
||
|
message += e.Body
|
||
|
log.LogInfo("Message created")
|
||
|
log.LogDebug(message)
|
||
|
log.LogInfo("Sending message")
|
||
|
err := smtp.SendMail(config.SmtpServer,
|
||
|
smtp.PlainAuth("", config.MyEmail, config.EmailPass, config.AuthServer),
|
||
|
config.MyEmail, e.Recipients, []byte(message))
|
||
|
if err != nil {
|
||
|
log.LogErrorType(err)
|
||
|
return
|
||
|
}
|
||
|
log.LogInfo("Email Sent")
|
||
|
}
|