mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
courier/smtp: Reorder EHLO domain logic
The logic that picks the domain we use for EHLO does not need to live within the TLS retry cycle, and makes it harder to understand. This patch moves it out of the way, to improve readability.
This commit is contained in:
@@ -54,6 +54,17 @@ func (s *SMTP) Deliver(from string, to string, data []byte) (error, bool) {
|
|||||||
}
|
}
|
||||||
tr.Debugf("MX: %s", mx)
|
tr.Debugf("MX: %s", mx)
|
||||||
|
|
||||||
|
// Issue an EHLO with a valid domain; otherwise, some servers like postfix
|
||||||
|
// will complain.
|
||||||
|
helloDomain, err := idna.ToASCII(envelope.DomainOf(from))
|
||||||
|
if err != nil {
|
||||||
|
return tr.Errorf("Sender domain not IDNA compliant: %v", err), true
|
||||||
|
}
|
||||||
|
if helloDomain == "" {
|
||||||
|
// This can happen when sending bounces. Last resort.
|
||||||
|
helloDomain, _ = os.Hostname()
|
||||||
|
}
|
||||||
|
|
||||||
// Do we use insecure TLS?
|
// Do we use insecure TLS?
|
||||||
// Set as fallback when retrying.
|
// Set as fallback when retrying.
|
||||||
insecure := false
|
insecure := false
|
||||||
@@ -71,17 +82,7 @@ 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
|
if err = c.Hello(helloDomain); err != nil {
|
||||||
// will complain.
|
|
||||||
fromDomain, err := idna.ToASCII(envelope.DomainOf(from))
|
|
||||||
if err != nil {
|
|
||||||
return tr.Errorf("Sender domain not IDNA compliant: %v", err), true
|
|
||||||
}
|
|
||||||
if fromDomain == "" {
|
|
||||||
// This can happen when sending bounces. Last resort.
|
|
||||||
fromDomain, _ = os.Hostname()
|
|
||||||
}
|
|
||||||
if err = c.Hello(fromDomain); err != nil {
|
|
||||||
return tr.Errorf("Error saying hello: %v", err), false
|
return tr.Errorf("Error saying hello: %v", err), false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user