1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-07 17:47:14 +00:00

chasquid: Add "Received" email headers

This patch makes chasquid add "Received" email headers, after DATA completes
and before queueing.

We only use this for debugging purposes.
This commit is contained in:
Alberto Bertogli
2016-09-23 00:16:07 +01:00
parent 5f15b4e040
commit d05b8ef189
2 changed files with 62 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
package envelope
import (
"fmt"
"strings"
"blitiri.com.ar/go/chasquid/internal/set"
@@ -36,3 +37,14 @@ func DomainIn(addr string, locals *set.String) bool {
return locals.Has(domain)
}
func AddHeader(data []byte, k, v string) []byte {
// If the value contains newlines, indent them properly.
if v[len(v)-1] == '\n' {
v = v[:len(v)-1]
}
v = strings.Replace(v, "\n", "\n\t", -1)
header := []byte(fmt.Sprintf("%s: %s\n", k, v))
return append(header, data...)
}