Skip to content

Commit

Permalink
Add mutex locks to DSN option setters
Browse files Browse the repository at this point in the history
Mutex locks are added to ensure thread safety when setting DSN mail return and recipient notify options. This prevents data races in concurrent environments, improving the client's robustness.
  • Loading branch information
wneessen committed Nov 22, 2024
1 parent 45776c0 commit f9e8690
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,16 @@ func (c *Client) SetLogAuthData() {

// SetDSNMailReturnOption sets the DSN mail return option for the Mail method
func (c *Client) SetDSNMailReturnOption(d string) {
c.mutex.Lock()
c.dsnmrtype = d
c.mutex.Unlock()
}

// SetDSNRcptNotifyOption sets the DSN recipient notify option for the Mail method
func (c *Client) SetDSNRcptNotifyOption(d string) {
c.mutex.Lock()
c.dsnrntype = d
c.mutex.Unlock()
}

// HasConnection checks if the client has an active connection.
Expand Down

0 comments on commit f9e8690

Please sign in to comment.