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

Add NetDialTimeout to Dialer for per Dialer proxying (i.e. Google's A… #41

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Dialer struct {
// Whether we should retry mailing if the connection returned an error,
// defaults to true.
RetryFailure bool
// Overrides NetDialTimeout for this dialer
NetDialTimeout func(network, address string, timeout time.Duration) (net.Conn, error)
}

// NewDialer returns a new SMTP Dialer. The given parameters are used to connect
Expand Down Expand Up @@ -79,7 +81,11 @@ var NetDialTimeout = net.DialTimeout
// Dial dials and authenticates to an SMTP server. The returned SendCloser
// should be closed when done using it.
func (d *Dialer) Dial() (SendCloser, error) {
conn, err := NetDialTimeout("tcp", addr(d.Host, d.Port), d.Timeout)
ndt := NetDialTimeout
if d.NetDialTimeout != nil {
ndt = d.NetDialTimeout
}
conn, err := ndt("tcp", addr(d.Host, d.Port), d.Timeout)
if err != nil {
return nil, err
}
Expand Down