-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailer.go
97 lines (78 loc) · 2.19 KB
/
mailer.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"fmt"
"net/smtp"
"os"
)
func sendEmail(recipients []string, subject string, message string) {
from := "" // commIT email here
password := "" // commIT password here
host := "smtp.gmail.com"
// Its the default port of smtp server
port := "587"
mime := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"
body := []byte("Subject: " + subject + "\r\n" + mime + message)
auth := smtp.PlainAuth("", from, password, host)
err := smtp.SendMail(host+":"+port, auth, from, recipients, body)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Successfully sent mail to all user in toList")
}
func setResetPasswordEmail(recipients []string) {
subject := "Reset Password"
// use html so can add link/logo etc
message :=
`
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Reset Password</title>
<style>
body {
background-color: #FFFFFF; padding: 0; margin: 0;
}
</style>
</head>
<body>
<span style="font-size: 12px; line-height: 1.5; color: #333333;">
We have received a request to reset your password.
<br/><br/>
To reset your password, please follow the link below:
<br/>
<a href="www.google.com">reset password link</a>
<br/><br/>
If you did not request for a change in password, please contact us immediately.
</span>
</body>
`
sendEmail(recipients, subject, message)
}
func confirmSignUpEmail(recipients []string) {
subject := "Confirm Registration"
// use html so can add link/logo etc
message :=
`
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Confirm Registration</title>
<style>
body {
background-color: #FFFFFF; padding: 0; margin: 0;
}
</style>
</head>
<body">
<span style="font-size: 12px; line-height: 1.5; color: #333333;">
We have received a request to register a new account under this email.
<br/><br/>
To confirm your registration, please click on the link below:
<br/>
<a href="www.google.com">Confirm Registration</a>
<br/><br/>
If you did not sign up under this email, please contact us immediately.
</span>
</body>
`
sendEmail(recipients, subject, message)
}