-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (33 loc) · 1019 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"flag"
"log"
"time"
gomail "gopkg.in/gomail.v2"
)
var (
emailFrom = flag.String("email-from", "", "SMTP server from address")
emailTo = flag.String("email-to", "", "SMTP server to address")
emailHost = flag.String("email-host", "", "SMTP server name")
emailPort = flag.Int("email-port", 587, "SMTP server port")
emailUser = flag.String("email-user", "", "SMTP server username")
emailPassword = flag.String("email-password", "", "SMTP server password")
)
func main() {
flag.Parse()
body, files := GenerateCloudFront()
// Craft the email.
m := gomail.NewMessage()
m.SetHeader("From", *emailFrom)
m.SetHeader("To", *emailTo)
m.SetHeader("Subject", time.Now().Format("Binary downloads 2006-01-02"))
m.SetBody("text/html", body)
for _, f := range files {
m.Embed(f)
}
// Send mail.
d := gomail.NewDialer(*emailHost, *emailPort, *emailUser, *emailPassword)
if err := d.DialAndSend(m); err != nil {
log.Fatalf("could not send email: %v", err)
}
}