Debian Codegraph @

lib/hooks/mail-sent.go

raw
1 package hooks
2
3 import (
4 "fmt"
5
6 "git.sr.ht/~rjarry/aerc/config"
7 "github.com/emersion/go-message/mail"
8 )
9
10 type MailSent struct {
11 Account string
12 Backend string
13 Header *mail.Header
14 }
15
16 func (m *MailSent) Cmd() string {
17 return config.Hooks().MailSent
18 }
19
20 func (m *MailSent) Env() []string {
21 from, _ := mail.ParseAddress(m.Header.Get("From"))
22 env := []string{
23 fmt.Sprintf("AERC_ACCOUNT=%s", m.Account),
24 fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend),
25 fmt.Sprintf("AERC_FROM_NAME=%s", from.Name),
26 fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address),
27 fmt.Sprintf("AERC_SUBJECT=%s", m.Header.Get("Subject")),
28 fmt.Sprintf("AERC_TO=%s", m.Header.Get("To")),
29 fmt.Sprintf("AERC_CC=%s", m.Header.Get("Cc")),
30 }
31
32 return env
33 }