mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-09 17:55:57 +00:00
courier: Use the senders' domain when saying EHLO
Some servers, like postfix, will pay close attention to the domain we say as a part of the EHLO. By default, Go's smtp package will use "localhost", causing it to complain. This patch fixes that by using the envelope-from's domain. It's not clear if that's better than using what we are resolving to, but that's much more involved so we're going to do this for now.
This commit is contained in:
@@ -67,6 +67,12 @@ retry:
|
|||||||
return tr.Errorf("Error creating client: %v", err), false
|
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
|
// TODO: Keep track of hosts and MXs that we've successfully done TLS
|
||||||
// against, and enforce it.
|
// against, and enforce it.
|
||||||
if ok, _ := c.Extension("STARTTLS"); ok {
|
if ok, _ := c.Extension("STARTTLS"); ok {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func TestSMTP(t *testing.T) {
|
|||||||
|
|
||||||
responses := map[string]string{
|
responses := map[string]string{
|
||||||
"_welcome": "220 welcome\n",
|
"_welcome": "220 welcome\n",
|
||||||
"EHLO localhost": "250 ehlo ok\n",
|
"EHLO me": "250 ehlo ok\n",
|
||||||
"MAIL FROM:<me@me>": "250 mail ok\n",
|
"MAIL FROM:<me@me>": "250 mail ok\n",
|
||||||
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
||||||
"DATA": "354 send data\n",
|
"DATA": "354 send data\n",
|
||||||
@@ -93,14 +93,14 @@ func TestSMTPErrors(t *testing.T) {
|
|||||||
// MAIL FROM not allowed.
|
// MAIL FROM not allowed.
|
||||||
{
|
{
|
||||||
"_welcome": "220 mail from not allowed\n",
|
"_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",
|
"MAIL FROM:<me@me>": "501 mail error\n",
|
||||||
},
|
},
|
||||||
|
|
||||||
// RCPT TO not allowed.
|
// RCPT TO not allowed.
|
||||||
{
|
{
|
||||||
"_welcome": "220 rcpt to not allowed\n",
|
"_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",
|
"MAIL FROM:<me@me>": "250 mail ok\n",
|
||||||
"RCPT TO:<to@to>": "501 rcpt error\n",
|
"RCPT TO:<to@to>": "501 rcpt error\n",
|
||||||
},
|
},
|
||||||
@@ -108,7 +108,7 @@ func TestSMTPErrors(t *testing.T) {
|
|||||||
// DATA error.
|
// DATA error.
|
||||||
{
|
{
|
||||||
"_welcome": "220 data error\n",
|
"_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",
|
"MAIL FROM:<me@me>": "250 mail ok\n",
|
||||||
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
||||||
"DATA": "554 data error\n",
|
"DATA": "554 data error\n",
|
||||||
@@ -117,7 +117,7 @@ func TestSMTPErrors(t *testing.T) {
|
|||||||
// DATA response error.
|
// DATA response error.
|
||||||
{
|
{
|
||||||
"_welcome": "220 data response error\n",
|
"_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",
|
"MAIL FROM:<me@me>": "250 mail ok\n",
|
||||||
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
"RCPT TO:<to@to>": "250 rcpt ok\n",
|
||||||
"DATA": "354 send data\n",
|
"DATA": "354 send data\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user