mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Compare commits
7 commits
188386098e
...
719b77899d
Author | SHA1 | Date | |
---|---|---|---|
|
719b77899d | ||
b4aa414a4d | |||
0f46ce800e | |||
03e53cbabc | |||
632ac17845 | |||
a5fcb3ae8b | |||
|
8c4eb62360 |
3 changed files with 11 additions and 2 deletions
|
@ -996,7 +996,7 @@ func (c *Client) DialWithContext(dialCtx context.Context) error {
|
|||
// Returns:
|
||||
// - An error if the disconnection fails; otherwise, returns nil.
|
||||
func (c *Client) Close() error {
|
||||
if !c.smtpClient.HasConnection() {
|
||||
if c.smtpClient == nil || !c.smtpClient.HasConnection() {
|
||||
return nil
|
||||
}
|
||||
if err := c.smtpClient.Quit(); err != nil {
|
||||
|
|
|
@ -1647,6 +1647,15 @@ func TestClient_Close(t *testing.T) {
|
|||
t.Errorf("close was supposed to fail, but didn't")
|
||||
}
|
||||
})
|
||||
t.Run("close on a nil smtpclient should return nil", func(t *testing.T) {
|
||||
client, err := NewClient(DefaultHost)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create new client: %s", err)
|
||||
}
|
||||
if err = client.Close(); err != nil {
|
||||
t.Errorf("failed to close the client: %s", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestClient_DialWithContext(t *testing.T) {
|
||||
|
|
2
doc.go
2
doc.go
|
@ -11,4 +11,4 @@ package mail
|
|||
|
||||
// VERSION indicates the current version of the package. It is also attached to the default user
|
||||
// agent string.
|
||||
const VERSION = "0.5.1"
|
||||
const VERSION = "0.5.2"
|
||||
|
|
Loading…
Reference in a new issue