Skip to content

Commit 1c8b290

Browse files
author
Winni Neessen
committed
Add error check for nil SMTP authentication method
Ensure that the SMTP authentication method is not nil by adding a corresponding error check in the WithSMTPAuthCustom function. Introduced a new error, ErrSMTPAuthMethodIsNil, to handle this validation.
1 parent ab835b7 commit 1c8b290

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ var (
242242
// provided as argument to the WithDSN Option.
243243
ErrInvalidDSNRcptNotifyCombination = errors.New("DSN rcpt notify option NEVER cannot be " +
244244
"combined with any of SUCCESS, FAILURE or DELAY")
245+
246+
// ErrSMTPAuthMethodIsNil indicates that the SMTP authentication method provided is nil
247+
ErrSMTPAuthMethodIsNil = errors.New("SMTP auth method is nil")
245248
)
246249

247250
// NewClient creates a new Client instance with the provided host and optional configuration Option functions.
@@ -510,6 +513,9 @@ func WithSMTPAuth(authtype SMTPAuthType) Option {
510513
// - An Option function that sets the custom SMTP authentication for the Client.
511514
func WithSMTPAuthCustom(smtpAuth smtp.Auth) Option {
512515
return func(c *Client) error {
516+
if smtpAuth == nil {
517+
return ErrSMTPAuthMethodIsNil
518+
}
513519
c.smtpAuth = smtpAuth
514520
c.smtpAuthType = SMTPAuthCustom
515521
return nil

0 commit comments

Comments
 (0)