-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemail.go
35 lines (31 loc) · 872 Bytes
/
email.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
package main
import (
"context"
"github.com/mrz1836/postmark"
"log"
"os"
)
var emailClient *postmark.Client
func emailSetup() {
emailClient = postmark.NewClient(os.Getenv("POSTMARK_SERVER_TOKEN"), os.Getenv("POSTMARK_ACCOUNT_TOKEN"))
email := postmark.Email{
From: "[email protected]",
To: "[email protected]",
Subject: "OpenElect is Up",
TextBody: "OpenElect is up and running!",
}
_, err := emailClient.SendEmail(context.Background(), email)
if err != nil {
log.Fatalf("Error sending email: %v", err)
}
}
func sendEmail(from string, to string, subject string, body string) error {
email := postmark.Email{
From: from,
To: to,
Subject: subject,
TextBody: body + "\n\nThis is an automated message sent from OpenElect.",
}
_, err := emailClient.SendEmail(context.Background(), email)
return err
}