mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-20 02:57:05 +00:00
add reject from origin domain feature (#375)
Add a new feature to be able to reject email *from* specific domains. Co-authored-by: Cyril DUPONT <cyd@9bis.com>
This commit is contained in:
20
pkg/policy/origin.go
Normal file
20
pkg/policy/origin.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package policy
|
||||
|
||||
import (
|
||||
"net/mail"
|
||||
)
|
||||
|
||||
// Origin represents a potential email origin, allows policies for it to be queried.
|
||||
type Origin struct {
|
||||
mail.Address
|
||||
addrPolicy *Addressing
|
||||
// LocalPart is the part of the address before @, including +extension.
|
||||
LocalPart string
|
||||
// Domain is the part of the address after @.
|
||||
Domain string
|
||||
}
|
||||
|
||||
// ShouldAccept returns true if Inbucket should accept mail from this origin.
|
||||
func (o *Origin) ShouldAccept() bool {
|
||||
return o.addrPolicy.ShouldAcceptOriginDomain(o.Domain)
|
||||
}
|
||||
Reference in New Issue
Block a user