mailer/init.go

38 lines
1 KiB
Go
Raw Permalink Normal View History

2025-01-12 13:03:17 +00:00
package mailer
import (
"strconv"
"sync/atomic"
)
type Mailer struct {
Password string
HostOnly string
HostWithPort string
From string
Footer string
UnsubscribeUrl string
UnsubscribeCodeFn UnsubFunc
Send map[string]func(email string)
SendKeyed map[string]func(email string, code string)
mail_counter *atomic.Uint64
wanted_send *atomic.Uint64
}
// UnsubscribeFunc should take a username and create an opaque string
type UnsubFunc func(username string) string
// New creates a mailer with your configured settings
func New(from string, password string, host string, port int, unsubscribe string, footer string, unsub UnsubFunc) Mailer {
p := strconv.FormatInt(int64(port), 10)
return Mailer{
Password: password, // utils.GlobalConfig.SMTP_PASSWORD
From: from,
HostOnly: host,
HostWithPort: host + ":" + p,
Footer: footer,
UnsubscribeUrl: unsubscribe,
UnsubscribeCodeFn: unsub,
}
}