1package server
2
3import "fmt"
4
5func (s *Server) sendWelcomeMail(email, handle string) error {
6 s.mailLk.Lock()
7 defer s.mailLk.Unlock()
8
9 s.mail.To(email)
10 s.mail.Subject("Welcome to " + s.config.Hostname)
11 s.mail.Plain().Set(fmt.Sprintf("Welcome to %s! Your handle is %s.", email, handle))
12
13 if err := s.mail.Send(); err != nil {
14 return err
15 }
16
17 return nil
18}
19
20func (s *Server) sendPasswordReset(email, handle, code string) error {
21 s.mailLk.Lock()
22 defer s.mailLk.Unlock()
23
24 s.mail.To(email)
25 s.mail.Subject("Password reset for " + s.config.Hostname)
26 s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your password reset code is %s. This code will expire in ten minutes.", handle, code))
27
28 if err := s.mail.Send(); err != nil {
29 return err
30 }
31
32 return nil
33}
34
35func (s *Server) sendEmailUpdate(email, handle, code string) error {
36 s.mailLk.Lock()
37 defer s.mailLk.Unlock()
38
39 s.mail.To(email)
40 s.mail.Subject("Email update for " + s.config.Hostname)
41 s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your email update code is %s. This code will expire in ten minutes.", handle, code))
42
43 if err := s.mail.Send(); err != nil {
44 return err
45 }
46
47 return nil
48}
49
50func (s *Server) sendEmailVerification(email, handle, code string) error {
51 s.mailLk.Lock()
52 defer s.mailLk.Unlock()
53
54 s.mail.To(email)
55 s.mail.Subject("Email verification for " + s.config.Hostname)
56 s.mail.Plain().Set(fmt.Sprintf("Hello %s. Your email verification code is %s. This code will expire in ten minutes.", handle, code))
57
58 if err := s.mail.Send(); err != nil {
59 return err
60 }
61
62 return nil
63}