-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.go
47 lines (35 loc) · 1.07 KB
/
send.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
package main
import(
"fmt"
"github.com/jordan-wright/email"
"github.com/russross/blackfriday"
)
// TODO: use text template api
const texttempl = `### Hi there!
%v asked you recently if you could have a look at [A Thing](%v). It would be much appreciated if you could find a few minutes to do so.
[%v](%v)
Once you're finished, you can mark yourself 'done' in the '[edit](%v)' form.
Thank you very much for taking the time.
*Thingtracker*`
func (t *Thing) EmailParticipants() error {
if len(t.Participants) == 0 {
return nil
}
showurl := fmt.Sprint(URL_ROOT, "/show/", t.Id)
editurl := fmt.Sprint(URL_ROOT, "/edit/", t.Id)
e := email.NewEmail()
e.From = t.Owner.Email
e.To = []string{}
for _,p := range t.Participants {
if !p.Done {
e.To = append(e.To, p.Email)
}
}
e.Subject = "A friendly reminder..."
e.Text = []byte(fmt.Sprintf(texttempl, t.Owner.Email, showurl, t.ThingName, t.ThingLink, editurl))
e.HTML = []byte(blackfriday.MarkdownBasic(e.Text))
fmt.Printf("%v\n", e.To)
println(string(e.Text))
return e.Send("MAILHOST:25", nil)
// return nil
}