From 4c96e6a11f62121b3900c1aef69d28090e5e9f23 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 6 Sep 2022 19:44:05 +0000 Subject: [PATCH] Apply 1 suggestion(s) to 1 file(s) --- smtp/mta.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/smtp/mta.go b/smtp/mta.go index b29ed66..3b7c44e 100644 --- a/smtp/mta.go +++ b/smtp/mta.go @@ -112,5 +112,14 @@ func (m *mta) connect(from, to string) (*smtp.Client, error) { } } + // If there are no MX records, according to https://datatracker.ietf.org/doc/html/rfc5321#section-5.1, + // we're supposed to try talking directly to the host. + if len(mxs) == 0 { + client := m.tryServer(localname, hostname) + if client != nil { + return client, nil + } + } + return nil, fmt.Errorf("target SMTP server not found") }