@@ -344,24 +344,24 @@ type conn struct {
344
344
}
345
345
346
346
type rcptAccount struct {
347
- accountName string
348
- destination config.Destination
349
- canonicalAddress string // Optional catchall part stripped and/or lowercased.
347
+ AccountName string
348
+ Destination config.Destination
349
+ CanonicalAddress string // Optional catchall part stripped and/or lowercased.
350
350
}
351
351
352
352
type rcptAlias struct {
353
- alias config.Alias
354
- canonicalAddress string // Optional catchall part stripped and/or lowercased.
353
+ Alias config.Alias
354
+ CanonicalAddress string // Optional catchall part stripped and/or lowercased.
355
355
}
356
356
357
357
type recipient struct {
358
- addr smtp.Path
358
+ Addr smtp.Path
359
359
360
360
// If account and alias are both not set, this is not for a local address. This is
361
361
// normal for submission, where messages are added to the queue. For incoming
362
362
// deliveries, this will result in an error.
363
- account * rcptAccount // If set, recipient address is for this local account.
364
- alias * rcptAlias // If set, for a local alias.
363
+ Account * rcptAccount // If set, recipient address is for this local account.
364
+ Alias * rcptAlias // If set, for a local alias.
365
365
}
366
366
367
367
func isClosed (err error ) bool {
@@ -1732,7 +1732,7 @@ func (c *conn) isSMTPUTF8Required(part *message.Part) bool {
1732
1732
}
1733
1733
// Check all "RCPT TO".
1734
1734
for _ , rcpt := range c .recipients {
1735
- if hasNonASCII (strings .NewReader (string (rcpt .addr .Localpart ))) {
1735
+ if hasNonASCII (strings .NewReader (string (rcpt .Addr .Localpart ))) {
1736
1736
return true
1737
1737
}
1738
1738
}
@@ -2037,7 +2037,7 @@ func (c *conn) submit(ctx context.Context, recvHdrFor func(string) string, msgWr
2037
2037
err = c .account .DB .Read (ctx , func (tx * bstore.Tx ) error {
2038
2038
rcpts := make ([]smtp.Path , len (c .recipients ))
2039
2039
for i , r := range c .recipients {
2040
- rcpts [i ] = r .addr
2040
+ rcpts [i ] = r .Addr
2041
2041
}
2042
2042
msglimit , rcptlimit , err := c .account .SendLimitReached (tx , rcpts )
2043
2043
xcheckf (err , "checking sender limit" )
@@ -2136,7 +2136,7 @@ func (c *conn) submit(ctx context.Context, recvHdrFor func(string) string, msgWr
2136
2136
qml := make ([]queue.Msg , len (c .recipients ))
2137
2137
for i , rcpt := range c .recipients {
2138
2138
if Localserve {
2139
- code , timeout := mox .LocalserveNeedsError (rcpt .addr .Localpart )
2139
+ code , timeout := mox .LocalserveNeedsError (rcpt .Addr .Localpart )
2140
2140
if timeout {
2141
2141
c .log .Info ("timing out submission due to special localpart" )
2142
2142
mox .Sleep (mox .Context , time .Hour )
@@ -2160,11 +2160,11 @@ func (c *conn) submit(ctx context.Context, recvHdrFor func(string) string, msgWr
2160
2160
// messages in a single smtp transaction.
2161
2161
var rcptTo string
2162
2162
if len (c .recipients ) == 1 {
2163
- rcptTo = rcpt .addr .String ()
2163
+ rcptTo = rcpt .Addr .String ()
2164
2164
}
2165
2165
xmsgPrefix := append ([]byte (recvHdrFor (rcptTo )), msgPrefix ... )
2166
2166
msgSize := int64 (len (xmsgPrefix )) + msgWriter .Size
2167
- qm := queue .MakeMsg (fp , rcpt .addr , msgWriter .Has8bit , c .msgsmtputf8 , msgSize , messageID , xmsgPrefix , c .requireTLS , now , header .Get ("Subject" ))
2167
+ qm := queue .MakeMsg (fp , rcpt .Addr , msgWriter .Has8bit , c .msgsmtputf8 , msgSize , messageID , xmsgPrefix , c .requireTLS , now , header .Get ("Subject" ))
2168
2168
if ! c .futureRelease .IsZero () {
2169
2169
qm .NextAttempt = c .futureRelease
2170
2170
qm .FutureReleaseRequest = c .futureReleaseRequest
@@ -2190,15 +2190,15 @@ func (c *conn) submit(ctx context.Context, recvHdrFor func(string) string, msgWr
2190
2190
for i , rcpt := range c .recipients {
2191
2191
c .log .Info ("messages queued for delivery" ,
2192
2192
slog .Any ("mailfrom" , * c .mailFrom ),
2193
- slog .Any ("rcptto" , rcpt .addr ),
2193
+ slog .Any ("rcptto" , rcpt .Addr ),
2194
2194
slog .Bool ("smtputf8" , c .smtputf8 ),
2195
2195
slog .Bool ("msgsmtputf8" , c .msgsmtputf8 ),
2196
2196
slog .Int64 ("msgsize" , qml [i ].Size ))
2197
2197
}
2198
2198
2199
2199
err = c .account .DB .Write (ctx , func (tx * bstore.Tx ) error {
2200
2200
for _ , rcpt := range c .recipients {
2201
- outgoing := store.Outgoing {Recipient : rcpt .addr .XString (true )}
2201
+ outgoing := store.Outgoing {Recipient : rcpt .Addr .XString (true )}
2202
2202
if err := tx .Insert (& outgoing ); err != nil {
2203
2203
return fmt .Errorf ("adding outgoing message: %v" , err )
2204
2204
}
@@ -2418,7 +2418,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2418
2418
// Give immediate response if all recipients are unknown.
2419
2419
nunknown := 0
2420
2420
for _ , r := range c .recipients {
2421
- if r .account == nil && r .alias == nil {
2421
+ if r .Account == nil && r .Alias == nil {
2422
2422
nunknown ++
2423
2423
}
2424
2424
}
@@ -2653,7 +2653,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2653
2653
}
2654
2654
var deliverErrors []deliverError
2655
2655
addError := func (rcpt recipient , code int , secode string , userError bool , errmsg string ) {
2656
- e := deliverError {rcpt .addr , code , secode , userError , errmsg }
2656
+ e := deliverError {rcpt .Addr , code , secode , userError , errmsg }
2657
2657
c .log .Info ("deliver error" ,
2658
2658
slog .Any ("rcptto" , e .rcptTo ),
2659
2659
slog .Int ("code" , code ),
@@ -2666,9 +2666,9 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2666
2666
// Sort recipients: local accounts, aliases, unknown. For ensuring we don't deliver
2667
2667
// to an alias destination that was also explicitly sent to.
2668
2668
rcptScore := func (r recipient ) int {
2669
- if r .account != nil {
2669
+ if r .Account != nil {
2670
2670
return 0
2671
- } else if r .alias != nil {
2671
+ } else if r .Alias != nil {
2672
2672
return 1
2673
2673
}
2674
2674
return 2
@@ -2682,9 +2682,9 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2682
2682
// addressee. Relies on c.recipients being sorted as above.
2683
2683
regularRecipient := func (addr smtp.Path ) bool {
2684
2684
for _ , rcpt := range c .recipients {
2685
- if rcpt .account == nil {
2685
+ if rcpt .Account == nil {
2686
2686
break
2687
- } else if rcpt .addr .Equal (addr ) {
2687
+ } else if rcpt .Addr .Equal (addr ) {
2688
2688
return true
2689
2689
}
2690
2690
}
@@ -2761,7 +2761,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2761
2761
// we will consider a message delivered if we delivered it to at least one account
2762
2762
// (others may be over quota).
2763
2763
processRecipient := func (rcpt recipient ) {
2764
- log := c .log .With (slog .Any ("mailfrom" , c .mailFrom ), slog .Any ("rcptto" , rcpt .addr ))
2764
+ log := c .log .With (slog .Any ("mailfrom" , c .mailFrom ), slog .Any ("rcptto" , rcpt .Addr ))
2765
2765
2766
2766
// If this is not a valid local user, we send back a DSN. This can only happen when
2767
2767
// there are also valid recipients, and only when remote is SPF-verified, so the DSN
@@ -2771,7 +2771,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2771
2771
// deliveries, and return an error at the end? Though the failure conditions will
2772
2772
// probably prevent any other successful deliveries too...
2773
2773
// We'll continue delivering to other recipients. ../rfc/5321:3275
2774
- if rcpt .account == nil && rcpt .alias == nil {
2774
+ if rcpt .Account == nil && rcpt .Alias == nil {
2775
2775
metricDelivery .WithLabelValues ("unknownuser" , "" ).Inc ()
2776
2776
addError (rcpt , smtp .C550MailboxUnavail , smtp .SeAddr1UnknownDestMailbox1 , true , "no such user" )
2777
2777
return
@@ -2792,17 +2792,17 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2792
2792
// check. We check all alias destinations, even if we already explicitly delivered
2793
2793
// to them: they may be the only destination that would accept the message.
2794
2794
var a0 * analysis // Analysis we've used for accept/reject decision.
2795
- if rcpt .alias != nil {
2795
+ if rcpt .Alias != nil {
2796
2796
// Check if msgFrom address is acceptable. This doesn't take validation into
2797
2797
// consideration. If the header was forged, the message may be rejected later on.
2798
- if ! aliasAllowedMsgFrom (rcpt .alias . alias , msgFrom ) {
2798
+ if ! aliasAllowedMsgFrom (rcpt .Alias . Alias , msgFrom ) {
2799
2799
addError (rcpt , smtp .C550MailboxUnavail , smtp .SePol7ExpnProhibited2 , true , "not allowed to send to destination" )
2800
2800
return
2801
2801
}
2802
2802
2803
- la = make ([]analysis , 0 , len (rcpt .alias . alias .ParsedAddresses ))
2804
- for _ , aa := range rcpt .alias . alias .ParsedAddresses {
2805
- a , err := messageAnalyze (log , rcpt .addr , aa .Address .Path (), aa .AccountName , aa .Destination , rcpt .alias . canonicalAddress )
2803
+ la = make ([]analysis , 0 , len (rcpt .Alias . Alias .ParsedAddresses ))
2804
+ for _ , aa := range rcpt .Alias . Alias .ParsedAddresses {
2805
+ a , err := messageAnalyze (log , rcpt .Addr , aa .Address .Path (), aa .AccountName , aa .Destination , rcpt .Alias . CanonicalAddress )
2806
2806
if err != nil {
2807
2807
addError (rcpt , smtp .C451LocalErr , smtp .SeSys3Other0 , false , "error processing" )
2808
2808
return
@@ -2818,7 +2818,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2818
2818
a0 = & la [0 ]
2819
2819
}
2820
2820
} else {
2821
- a , err := messageAnalyze (log , rcpt .addr , rcpt .addr , rcpt .account . accountName , rcpt .account . destination , rcpt .account . canonicalAddress )
2821
+ a , err := messageAnalyze (log , rcpt .Addr , rcpt .Addr , rcpt .Account . AccountName , rcpt .Account . Destination , rcpt .Account . CanonicalAddress )
2822
2822
if err != nil {
2823
2823
addError (rcpt , smtp .C451LocalErr , smtp .SeSys3Other0 , false , "error processing" )
2824
2824
return
@@ -2893,7 +2893,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2893
2893
"Return-Path: <" + c .mailFrom .String () + ">\r \n " + // ../rfc/5321:3300
2894
2894
rcptAuthResults .Header () +
2895
2895
receivedSPF .Header () +
2896
- recvHdrFor (rcpt .addr .String ()),
2896
+ recvHdrFor (rcpt .Addr .String ()),
2897
2897
)
2898
2898
la [i ].d .m .Size += int64 (len (la [i ].d .m .MsgPrefix ))
2899
2899
}
@@ -2986,7 +2986,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
2986
2986
Disposition : disposition ,
2987
2987
AlignedDKIMPass : dmarcResult .AlignedDKIMPass ,
2988
2988
AlignedSPFPass : dmarcResult .AlignedSPFPass ,
2989
- EnvelopeTo : rcpt .addr .IPDomain .String (),
2989
+ EnvelopeTo : rcpt .Addr .IPDomain .String (),
2990
2990
EnvelopeFrom : c .mailFrom .IPDomain .String (),
2991
2991
HeaderFrom : msgFrom .Domain .Name (),
2992
2992
}
@@ -3034,7 +3034,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
3034
3034
if ! a0 .accept {
3035
3035
for _ , a := range la {
3036
3036
// Don't add message if address was also explicitly present in a RCPT TO command.
3037
- if rcpt .alias != nil && regularRecipient (a .d .deliverTo ) {
3037
+ if rcpt .Alias != nil && regularRecipient (a .d .deliverTo ) {
3038
3038
continue
3039
3039
}
3040
3040
@@ -3084,7 +3084,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
3084
3084
}
3085
3085
3086
3086
delayFirstTime := true
3087
- if rcpt .account != nil && a0 .dmarcReport != nil {
3087
+ if rcpt .Account != nil && a0 .dmarcReport != nil {
3088
3088
// todo future: add rate limiting to prevent DoS attacks. ../rfc/7489:2570
3089
3089
if err := dmarcdb .AddReport (ctx , a0 .dmarcReport , msgFrom .Domain ); err != nil {
3090
3090
log .Errorx ("saving dmarc aggregate report in database" , err )
@@ -3094,7 +3094,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
3094
3094
delayFirstTime = false
3095
3095
}
3096
3096
}
3097
- if rcpt .account != nil && a0 .tlsReport != nil {
3097
+ if rcpt .Account != nil && a0 .tlsReport != nil {
3098
3098
// todo future: add rate limiting to prevent DoS attacks.
3099
3099
if err := tlsrptdb .AddReport (ctx , c .log , msgFrom .Domain , c .mailFrom .String (), a0 .d .destination .HostTLSReports , a0 .tlsReport ); err != nil {
3100
3100
log .Errorx ("saving TLSRPT report in database" , err )
@@ -3115,7 +3115,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
3115
3115
}
3116
3116
3117
3117
if Localserve {
3118
- code , timeout := mox .LocalserveNeedsError (rcpt .addr .Localpart )
3118
+ code , timeout := mox .LocalserveNeedsError (rcpt .Addr .Localpart )
3119
3119
if timeout {
3120
3120
log .Info ("timing out due to special localpart" )
3121
3121
mox .Sleep (mox .Context , time .Hour )
@@ -3147,7 +3147,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
3147
3147
for _ , a := range la {
3148
3148
// Don't deliver to recipient that was explicitly present in SMTP transaction, or
3149
3149
// is sending the message to an alias they are member of.
3150
- if rcpt .alias != nil && (regularRecipient (a .d .deliverTo ) || a .d .deliverTo .Equal (msgFrom .Path ())) {
3150
+ if rcpt .Alias != nil && (regularRecipient (a .d .deliverTo ) || a .d .deliverTo .Equal (msgFrom .Path ())) {
3151
3151
continue
3152
3152
}
3153
3153
0 commit comments