summaryrefslogtreecommitdiff
path: root/app/controllers/mail.go
blob: 3fd2e94c5a6d6ef3cadae1a7e45106678c82132e (plain)
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
package controllers

import (
	"github.com/tanema/revel_mailer"
)

type Mailer struct {
	revel_mailer.Mailer
}

type JobConfirmationKey struct {
	Email string
	Key   string
}

func (j JobConfirmationKey) Run() {
	_ = Mailer{}.SendConfirmationKey(j.Email, j.Key)
}

func (u Mailer) SendConfirmationKey(email, key string) error {
	return u.Send(revel_mailer.H{
		"subject": "Confirmation Key",
		"to":      []string{email},
		"key":     key,
	})
}

type JobRegistration struct {
	User  string
	Email string
	Key   string
}

func (j JobRegistration) Run() {
	_ = Mailer{}.ConfirmRegistration(j.User, j.Email, j.Key)
}

func (u Mailer) ConfirmRegistration(user, email, key string) error {
	return u.Send(revel_mailer.H{
		"name":    user,
		"subject": "Confirm registration",
		"to":      []string{email},
		"key":     key,
	})
}