Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.
Merged
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
7 changes: 6 additions & 1 deletion pkg/email/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package email
import (
"context"
"net/smtp"
"time"

"github.com/google/exposure-notifications-server/pkg/logging"
)
Expand All @@ -44,10 +45,14 @@ func NewSMTP(ctx context.Context, user, password, host, port string) Provider {

// SendEmail sends an email to the user.
func (s *SMTPProvider) SendEmail(ctx context.Context, toEmail string, message []byte) error {
ctx, done := context.WithTimeout(context.Background(), 60*time.Second)

// Authentication.
auth := smtp.PlainAuth("", s.User, s.Password, s.SMTPHost)
go s.sendMail(ctx, auth, toEmail, message)
go func() {
defer done()
s.sendMail(ctx, auth, toEmail, message)
}()

return nil
}
Expand Down