mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 20:51:43 +00:00
Before, the smtp.Dial function had no cancellation mechanism - meaning
that you could be waiting for several minutes to try to establish a
connection before it gives up.
I work around this by establishing a TCP connection myself to the
appropriate address, and using
[net.DialContext](https://pkg.go.dev/net#Dialer.DialContext) to cancel
the dial process if either:
1. The parent context cancels
2. 30 seconds have passed
Afterwards, we construct the smtp.Client ourselves using
[smtp.NewClient](https://pkg.go.dev/net/smtp#NewClient)
This only changes what happens when we try to establish a connection -
it doesn't change any behavior around sending emails afterwards.
## Test plan
Manual testing.
1. On local dev, I edited the credentials in the [dev-private site
configuration file
](
|
||
|---|---|---|
| .. | ||
| txtypes | ||
| BUILD.bazel | ||
| siteconfig.go | ||
| template_test.go | ||
| template.go | ||
| txemail_test.go | ||
| txemail.go | ||