Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Hanging Connection #67

Open
MichaHoffmann opened this issue Jul 8, 2020 · 1 comment
Open

Hanging Connection #67

MichaHoffmann opened this issue Jul 8, 2020 · 1 comment

Comments

@MichaHoffmann
Copy link

The connection deadline is only set after smtpNewClient was called. Since smtpNewClient already wants to read 220 from the connection, a server that does not respond will result in a hanging connection.

This issue should be resolvable by moving the deadline code just after creation of the connection.

func (d *Dialer) Dial() (SendCloser, error) {
	conn, err := NetDialTimeout("tcp", addr(d.Host, d.Port), d.Timeout)
	if err != nil {
		return nil, err
	}

	if d.SSL {
		conn = tlsClient(conn, d.tlsConfig())
	}

	c, err := smtpNewClient(conn, d.Host)
	if err != nil {
		return nil, err
	}

	if d.Timeout > 0 {
		conn.SetDeadline(time.Now().Add(d.Timeout))
	}
@afk11
Copy link

afk11 commented Jul 27, 2020

Duplicate of #49

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants