mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-23 15:37:01 +00:00
Introduce an "envelope" package
This patch introduces an "envelope" package which, for now, provides simple utilities for getting the user and domain of an address. It also changes the couriers to use it (but other implementations remain, will be moved over in subsequent patches).
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"blitiri.com.ar/go/chasquid/internal/envelope"
|
||||
"blitiri.com.ar/go/chasquid/internal/trace"
|
||||
)
|
||||
|
||||
@@ -36,13 +37,17 @@ func (p *Procmail) Deliver(from string, to string, data []byte) error {
|
||||
defer tr.Finish()
|
||||
|
||||
// Get the user, and sanitize to be extra paranoid.
|
||||
user := sanitizeForProcmail(userOf(to))
|
||||
tr.LazyPrintf("%s -> %s (%s)", from, user, to)
|
||||
user := sanitizeForProcmail(envelope.UserOf(to))
|
||||
domain := sanitizeForProcmail(envelope.DomainOf(to))
|
||||
tr.LazyPrintf("%s -> %s (%s @ %s)", from, user, to, domain)
|
||||
|
||||
// Prepare the command, replacing the necessary arguments.
|
||||
replacer := strings.NewReplacer(
|
||||
"%user%", user,
|
||||
"%domain%", domain)
|
||||
args := []string{}
|
||||
for _, a := range MailDeliveryAgentArgs {
|
||||
args = append(args, strings.Replace(a, "%user%", user, -1))
|
||||
args = append(args, replacer.Replace(a))
|
||||
}
|
||||
cmd := exec.Command(MailDeliveryAgentBin, args...)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user