author | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-10-01 17:00:53 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-10-09 23:51:04 UTC |
parent | 280939c3ec46607cb15b78d19de43a3971a92424 |
internal/courier/smtp.go | +6 | -0 |
internal/courier/smtp_test.go | +5 | -5 |
diff --git a/internal/courier/smtp.go b/internal/courier/smtp.go index 5ef5c4b..28f2206 100644 --- a/internal/courier/smtp.go +++ b/internal/courier/smtp.go @@ -67,6 +67,12 @@ retry: return tr.Errorf("Error creating client: %v", err), false } + // Issue an EHLO with a valid domain; otherwise, some servers like postfix + // will complain. + if err = c.Hello(envelope.DomainOf(from)); err != nil { + return tr.Errorf("Error saying hello: %v", err), false + } + // TODO: Keep track of hosts and MXs that we've successfully done TLS // against, and enforce it. if ok, _ := c.Extension("STARTTLS"); ok { diff --git a/internal/courier/smtp_test.go b/internal/courier/smtp_test.go index 9324e1a..915b09c 100644 --- a/internal/courier/smtp_test.go +++ b/internal/courier/smtp_test.go @@ -59,7 +59,7 @@ func TestSMTP(t *testing.T) { responses := map[string]string{ "_welcome": "220 welcome\n", - "EHLO localhost": "250 ehlo ok\n", + "EHLO me": "250 ehlo ok\n", "MAIL FROM:<me@me>": "250 mail ok\n", "RCPT TO:<to@to>": "250 rcpt ok\n", "DATA": "354 send data\n", @@ -93,14 +93,14 @@ func TestSMTPErrors(t *testing.T) { // MAIL FROM not allowed. { "_welcome": "220 mail from not allowed\n", - "EHLO localhost": "250 ehlo ok\n", + "EHLO me": "250 ehlo ok\n", "MAIL FROM:<me@me>": "501 mail error\n", }, // RCPT TO not allowed. { "_welcome": "220 rcpt to not allowed\n", - "EHLO localhost": "250 ehlo ok\n", + "EHLO me": "250 ehlo ok\n", "MAIL FROM:<me@me>": "250 mail ok\n", "RCPT TO:<to@to>": "501 rcpt error\n", }, @@ -108,7 +108,7 @@ func TestSMTPErrors(t *testing.T) { // DATA error. { "_welcome": "220 data error\n", - "EHLO localhost": "250 ehlo ok\n", + "EHLO me": "250 ehlo ok\n", "MAIL FROM:<me@me>": "250 mail ok\n", "RCPT TO:<to@to>": "250 rcpt ok\n", "DATA": "554 data error\n", @@ -117,7 +117,7 @@ func TestSMTPErrors(t *testing.T) { // DATA response error. { "_welcome": "220 data response error\n", - "EHLO localhost": "250 ehlo ok\n", + "EHLO me": "250 ehlo ok\n", "MAIL FROM:<me@me>": "250 mail ok\n", "RCPT TO:<to@to>": "250 rcpt ok\n", "DATA": "354 send data\n",