MCPcopy Index your code
hub / github.com/foxcpp/maddy / Split

Function Split

framework/address/split.go:36–54  ·  view source on GitHub ↗

Split splits a email address (as defined by RFC 5321 as a forward-path token) into local part (mailbox) and domain. Note that definition of the forward-path token includes the special postmaster address without the domain part. Split will return domain == "" in this case. Split does almost no sani

(addr string)

Source from the content-addressed store, hash-verified

34// If this is a concern, ValidMailbox and ValidDomain should be used on the
35// output.
36func Split(addr string) (mailbox, domain string, err error) {
37 if strings.EqualFold(addr, "postmaster") {
38 return addr, "", nil
39 }
40
41 indx := strings.LastIndexByte(addr, '@')
42 if indx == -1 {
43 return "", "", errors.New("address: missing at-sign")
44 }
45 mailbox = addr[:indx]
46 domain = addr[indx+1:]
47 if mailbox == "" {
48 return "", "", errors.New("address: empty local-part")
49 }
50 if domain == "" {
51 return "", "", errors.New("address: empty domain")
52 }
53 return
54}
55
56// UnquoteMbox undoes escaping and quoting of the local-part. That is, for
57// local-part `"test\" @ test"` it will return `test" @test`.

Callers 15

ExtractFromDomainFunction · 0.92
releaseLimitsMethod · 0.92
startDeliveryMethod · 0.92
AuthorizeEmailUseFunction · 0.92
LookupMethod · 0.92
rewriteMethod · 0.92
RewriteBodyMethod · 0.92
srcBlockForAddrMethod · 0.92
rcptBlockForAddrMethod · 0.92
spfResultMethod · 0.92
prepareMailFromFunction · 0.92
checkListMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestSplitFunction · 0.68