Skip to content

Commit 46c1693

Browse files
committed
when delivering over smtp, do not require the other server to announce the 8bitmime extension unless in pedantic mode
all relevant systems nowadays should be accepting "8-bit" messages. before this change, we would fail delivery for 8bit messages when the remote server doesn't announce the 8bitmime smtp extension. even though that system would likely just accept our message. also, there's a good chance the non-8bitmime-supporting system is some intermediate minimal mail server like openbsd spamd, which was fixed to announce the 8bitmime extension in the past year. in theory, we could rewrite the message to be 7bit-only if it is a mime message. but it's probably not worth the trouble. also see https://cr.yp.to/smtp/8bitmime.html as alternative to PR #287 by mattanja (who also reported the issue on matrix), thanks!
1 parent 93b627c commit 46c1693

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

queue/direct.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,13 @@ func deliverHost(log mlog.Log, resolver dns.Resolver, dialer smtpclient.Dialer,
728728
rcpts[i] = mr.msg.Recipient().XString(m0.SMTPUTF8)
729729
}
730730

731-
resps, err := sc.DeliverMultiple(ctx, mailFrom, rcpts, size, msg, has8bit, smtputf8, m0.RequireTLS != nil && *m0.RequireTLS)
731+
// Only require that remote announces 8bitmime extension when in pedantic mode. All
732+
// relevant systems nowadays should accept "8-bit" messages, some unfortunately
733+
// don't announce support. In theory we could rewrite the submitted message to be
734+
// 7-bit-only, but the trouble likely isn't worth it.
735+
req8bit := has8bit && mox.Pedantic
736+
737+
resps, err := sc.DeliverMultiple(ctx, mailFrom, rcpts, size, msg, req8bit, smtputf8, m0.RequireTLS != nil && *m0.RequireTLS)
732738
if err != nil && (len(resps) == 0 && n == len(msgResps) || len(resps) == len(msgResps)) {
733739
// If error and it applies to all recipients, return a single error.
734740
return deliverResult{err: inspectError(err)}

smtpclient/client.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ func (c *Client) TLSConnectionState() *tls.ConnectionState {
10951095
// mailFrom must be an email address, or empty in case of a DSN. rcptTo must be
10961096
// an email address.
10971097
//
1098-
// If the message contains bytes with the high bit set, req8bitmime must be true. If
1099-
// set, the remote server must support the 8BITMIME extension or delivery will
1098+
// If the message contains bytes with the high bit set, req8bitmime should be true.
1099+
// If set, the remote server must support the 8BITMIME extension or delivery will
11001100
// fail.
11011101
//
11021102
// If the message is internationalized, e.g. when headers contain non-ASCII
@@ -1149,10 +1149,7 @@ func (c *Client) DeliverMultiple(ctx context.Context, mailFrom string, rcptTo []
11491149
}
11501150

11511151
if !c.ext8bitmime && req8bitmime {
1152-
// Temporary error, e.g. OpenBSD spamd does not announce 8bitmime support, but once
1153-
// you get through, the mail server behind it probably does. Just needs a few
1154-
// retries.
1155-
c.xerrorf(false, 0, "", "", nil, "%w", Err8bitmimeUnsupported)
1152+
c.xerrorf(true, 0, "", "", nil, "%w", Err8bitmimeUnsupported)
11561153
}
11571154
if !c.extSMTPUTF8 && reqSMTPUTF8 {
11581155
// ../rfc/6531:313

0 commit comments

Comments
 (0)