mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
Calling it a day...
This commit is contained in:
parent
6a497d2780
commit
5aebb12241
2 changed files with 19 additions and 0 deletions
15
client.go
15
client.go
|
@ -295,6 +295,18 @@ func (c *Client) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Reset sends the RSET command to the SMTP client
|
||||
func (c *Client) Reset() error {
|
||||
if err := c.checkConn(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.sc.Reset(); err != nil {
|
||||
return fmt.Errorf("failed to send RSET to SMTP client: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DialAndSend establishes a connection to the SMTP server with a
|
||||
// default context.Background and sends the mail
|
||||
func (c *Client) DialAndSend() error {
|
||||
|
@ -314,6 +326,9 @@ func (c *Client) checkConn() error {
|
|||
if c.co == nil {
|
||||
return ErrNoActiveConnection
|
||||
}
|
||||
if err := c.sc.Noop(); err != nil {
|
||||
return ErrNoActiveConnection
|
||||
}
|
||||
if err := c.co.SetDeadline(time.Now().Add(c.cto)); err != nil {
|
||||
return ErrDeadlineExtendFailed
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
defer func() {
|
||||
if err := c.Reset(); err != nil {
|
||||
fmt.Printf("failed to reset: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := c.Close(); err != nil {
|
||||
fmt.Printf("failed to close: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in a new issue