mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
policy: Implement recipient domain policy for #51
- INBUCKET_SMTP_DEFAULTACCEPT - INBUCKET_SMTP_ACCEPTDOMAINS - INBUCKET_SMTP_REJECTDOMAINS
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jhillyerd/inbucket/pkg/config"
|
||||
"github.com/jhillyerd/inbucket/pkg/stringutil"
|
||||
)
|
||||
|
||||
// Addressing handles email address policy.
|
||||
@@ -29,14 +30,26 @@ func (a *Addressing) NewRecipient(address string) (*Recipient, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &Recipient{
|
||||
Address: *ar,
|
||||
apolicy: a,
|
||||
LocalPart: local,
|
||||
Domain: domain,
|
||||
Mailbox: mailbox,
|
||||
Address: *ar,
|
||||
addrPolicy: a,
|
||||
LocalPart: local,
|
||||
Domain: domain,
|
||||
Mailbox: mailbox,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ShouldAcceptDomain indicates if Inbucket accepts mail destined for the specified domain.
|
||||
func (a *Addressing) ShouldAcceptDomain(domain string) bool {
|
||||
domain = strings.ToLower(domain)
|
||||
if a.Config.DefaultAccept && !stringutil.SliceContains(a.Config.RejectDomains, domain) {
|
||||
return true
|
||||
}
|
||||
if !a.Config.DefaultAccept && stringutil.SliceContains(a.Config.AcceptDomains, domain) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ShouldStoreDomain indicates if Inbucket stores email destined for the specified domain.
|
||||
func (a *Addressing) ShouldStoreDomain(domain string) bool {
|
||||
if a.Config.StoreMessages {
|
||||
|
||||
Reference in New Issue
Block a user