Comments only, no behaviour changed. Each main.cf/master.cf parameter the
build sets, the wrapper's and the reload hook's reliance on Postfix 3.7.11
(postfix-script, master.5, postconf.5, cleanup_init.c, smtpd_peer.c,
README_FILES), supervisor 4.2.5 (process.py, options.py, events.rst),
logrotate 3.21.0, OpenDKIM's config, Cyrus SASL's sasldb, rspamd 3.11.1
(milter_headers.lua, multimap, the map watcher), Docker Compose, CoreDNS
and certbot now say where that is written. Measurements already there stay
measurements ("date not recorded" where none was); hand-composed fixtures
say so.
Contradictions left for their own commits: C-P31 cleanup's size limit,
C-P42 master outside supervisor's signal, C-V5/V6 startsecs, C-V10,
C-S3/Q3 sasldb written in place, C-Q4/A1 certbot's symlinks, C-R7 rspamd
skips local clients but the signature routine does not, C-P8, C-R4, C-R12,
C-M7, C-E2, C-K8/K9, C-D1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package e2e
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"net/smtp"
|
|
"time"
|
|
)
|
|
|
|
// port25Addr is where compose.override.yml publishes port 25: no TLS required,
|
|
// no AUTH offered - a stranger's mail server talking to this one.
|
|
const port25Addr = "127.0.0.1:20025"
|
|
|
|
// deliverPort25 is one transaction on port 25 the way another mail server makes
|
|
// it: HELO, MAIL, RCPT, DATA with message as it stands. The result says at
|
|
// which stage it was refused, like attemptSend's.
|
|
func deliverPort25(from, to, message string) sendResult {
|
|
var res sendResult
|
|
conn, err := net.DialTimeout("tcp", port25Addr, 10*time.Second)
|
|
if err != nil {
|
|
res.dialErr = fmt.Errorf("dial %s: %w", port25Addr, err)
|
|
return res
|
|
}
|
|
c, err := smtp.NewClient(conn, selfpostHostname)
|
|
if err != nil {
|
|
res.dialErr = fmt.Errorf("smtp handshake: %w", err)
|
|
_ = conn.Close()
|
|
return res
|
|
}
|
|
defer c.Close()
|
|
if err := c.Hello("mx.stranger.e2e.test"); err != nil {
|
|
res.dialErr = err
|
|
return res
|
|
}
|
|
if err := c.Mail(from); err != nil {
|
|
res.mailErr = err
|
|
_ = c.Quit()
|
|
return res
|
|
}
|
|
if err := c.Rcpt(to); err != nil {
|
|
res.rcptErr = err
|
|
_ = c.Quit()
|
|
return res
|
|
}
|
|
w, err := c.Data()
|
|
if err != nil {
|
|
res.dataErr = err
|
|
_ = c.Quit()
|
|
return res
|
|
}
|
|
if _, err := w.Write([]byte(message)); err != nil {
|
|
res.dataErr = err
|
|
} else if err := w.Close(); err != nil {
|
|
res.dataErr = err
|
|
}
|
|
_ = c.Quit()
|
|
return res
|
|
}
|
|
|
|
// waitForPort25Ready polls port 25 until Postfix greets on it. A bare connect
|
|
// is not enough: Docker's proxy accepts on the published port whether or not
|
|
// anything listens behind it (seen on the stand, date not recorded - see
|
|
// waitForSMTPSReady).
|
|
func waitForPort25Ready(timeout time.Duration) error {
|
|
return waitFor("port 25 to greet", timeout, 500*time.Millisecond, func() (bool, error) {
|
|
conn, err := net.DialTimeout("tcp", port25Addr, 2*time.Second)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
defer conn.Close()
|
|
_ = conn.SetReadDeadline(time.Now().Add(3 * time.Second))
|
|
buf := make([]byte, 4)
|
|
n, err := conn.Read(buf)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if string(buf[:n]) != "220 " {
|
|
return false, fmt.Errorf("greeting starts with %q", buf[:n])
|
|
}
|
|
return true, nil
|
|
})
|
|
}
|