mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-23 02:50:39 +01:00
"Improve error checking in SMTP client creation"
A change was made in the SMTP client creation process to add more robust error handling. The new logic checks if the client is null after being created and, if true, returns an error. This update can help prevent potential null pointer exceptions in runtime, ultimately leading to more stable application.
This commit is contained in:
parent
cf678be9dd
commit
bb18ef9e93
1 changed files with 6 additions and 1 deletions
|
@ -511,10 +511,15 @@ func (c *Client) DialWithContext(pc context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
c.sc, err = smtp.NewClient(c.co, c.host)
|
||||
sc, err := smtp.NewClient(c.co, c.host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if sc == nil {
|
||||
return fmt.Errorf("SMTP client is nil")
|
||||
}
|
||||
c.sc = sc
|
||||
|
||||
if c.l != nil {
|
||||
c.sc.SetLogger(c.l)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue