Confirming that if I edit util.c and replace LINE_MAX with 65535 (since 
SMTPD_LINE_MAX is out of scope here) then I can successfully communicate with 
O365 mail servers.
Not sure what nasty side-effects that edit could have, though – looking for 
input!
-Adam


From: Adam Thompson
Sent: Wednesday, September 30, 2026 3:50 AM
To: '[email protected]' <[email protected]>
Subject: mta error reason=Bad response: line too long when talking to O365

Hi,
I’m having difficulty getting /usr/sbin/smtpd 7.9-STABLE to communicate 
successfully with O365, getting “Bad response: line too long” errors.
I’m using a secrets file to authenticate to O365 in order to relay mail; the 
opensmtpd instance in question is my internal SMTP relay… or at least that’s 
the intention, I don’t see any need for any other MTAs in such a 
straightforward application.

Looking at the output from a `-T all` invocation, and comparing that to 
smtp_client.c, I’m not sure I understand what the failing input is.
I see from `-T all`, in part:

[…everything is fine up until this point, I’ve connected, STARTTLS’d, and 
authenticated…]
mta: 0x28c3d5ef6d0: <<< 354 Start mail input; end with <CRLF>.<CRLF>
mta: 0x28c3d5ef6d0: MTA_DATA -> MTA_BODY
mta: 0x28c3d5ef6d0: >>> [...419 bytes...]
mta: 0x28c3d5ef6d0: IO_LOWAT <io:0x28c79fd6f00 fd=14 to=300000 fl=W 
tls=TLSv1.3:TLS_AES_256_GCM_SHA384 ib=0 ob=0>
mta: 0x28c3d5ef6d0: MTA_BODY -> MTA_BODY
mta: 0x28c3d5ef6d0: end-of-file
mta: 0x28c3d5ef6d0: MTA_BODY -> MTA_EOM
mta: 0x28c3d5ef6d0: >>> .
mta: 0x28c3d5ef6d0: IO_LOWAT <io:0x28c79fd6f00 fd=14 to=300000 fl=W 
tls=TLSv1.3:TLS_AES_256_GCM_SHA384 ib=0 ob=0>
mta: 0x28c3d5ef6d0: IO_DATAIN <io:0x28c79fd6f00 fd=14 to=300000 fl=R 
tls=TLSv1.3:TLS_AES_256_GCM_SHA384 ib=4381 ob=0>
mta: 0x28c3d5ef6d0: <<< 554 5.2.252 SendAsDenied; 
[email protected]<mailto:[email protected]> not allowed to send as 
[email protected]<mailto:[email protected]>;
 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; 
Failed to process message due to a permanent exception with message 
[BeginDiagnosticData]Cannot submit
message. 1.84300:01000000, 1.84300:0B000000, 1.84300:0A000000, 
1.84300:0A000000, 1.84300:0E000000, 1.84300:32000000, 1.73948:00000000, 
5.71140:67000000446F526F70730000, 1.108572:00000000, 0.117068:76657200, 
1.79180:0B000000, 1.79180:0A000000, 1.79180:0A000000, 1.79180:0E000000, 
1.79180:32000000, 1.79180:FA000000
, 255.73100:6E743D41, 5.95292:67000000446F526F70730072, 
8.111356:9552F9FE86593ECC1F1F572B2F8F6BAC1F1F572B, 0.38698:80DEE83A, 
1.41134:86000000, 1.98628:00000000, 1.41134:86000000, 1.98628:00000000, 
1.41134:86000000, 1.98628:00000000, 1.41134:46000000, 1.98628:00000000, 
0.37692:0A000000, 0.37948:00000000, 5.33852:0
0000000534D545000000000, 7.36354:010000000000010900000000, 1.46439:0A000000, 
1.115228:00000000, 0.104668:12000000, 1.44903:25000000, 1.115228:00000000, 
12.56248:DC04000053656E64417320636865636B206661696C65642062656375617365204149206973206E756C6C0000,
 7.40748:010000000000010B01000000, 7.57132:00000000000000000F010
480, 4.39640:DC040000, 1.63016:32000000, 
8.45434:888C4079C982DB429564573D7EFC63AA38662D36, 0.104348:34393162, 
5.46798:040000004D61696C4974656D5375626D697373696F6E00542031302E, 
7.51330:6E32E3BDC31EDF088F000100, 
5.10786:0000000031352E32312E303437322E3030353A595131505230314D4231313930323A64316565613638662D366634302D
343931622D616435352D3430623034373664643163313A383338303A2E4E45542031302E302E313100000000,
 0.39570:00000000, 1.55954:0B000000, 0.40818:02000000, 1.33010:0B000000, 
2.54258:00000000, 0.59634:02000000, 1.56562:00000000, 1.33010:0B000000, 
2.54258:00000000, 0.59634:00000000, 1.56562:00000000, 1.55954:0A000000, 1.33010:
0A000000, 2.54258:00000000, 0.40002:03000000, 1.56562:00000000, 
1.33010:0A000000, 2.54258:00000000, 0.40002:00000000, 1.56562:00000000, 
1.55954:0A000000, 1.33010:0A000000, 2.54258:00000000, 0.40002:00000000, 
1.56562:00000000, 1.33010:0A000000, 2.54258:00000000, 0.40002:01000000, 
1.56562:00000000, 1.64146:0E000000
, 1.33010:0E000000, 2.54258:00000000, 1.33010:0E000000, 2.54258:00000000, 
1.64146:32000000, 1.33010:32000000, 2.54258:DC040000, 1.33010:32000000, 
2.54258:DC040000, 255.79500:00000000, 0.100684:00000000, 255.66700:00000000, 
5.95292:67000000446F526F70730072, 
8.111356:9552F9FE86593ECC1F1F572B2F8F6BAC1F1F572B, 0.3869
8:80DEE83A, 1.41134:86000000, 1.98628:00000000, 1.41134:86000000, 
1.98628:00000000, 1.41134:86000000, 1.98628:00000000, 1.41134:46000000, 
1.98628:00000000, 0.37692:0A000000, 0.37948:00000000, 
5.33852:00000000534D545000000000, 7.36354:010000000000010900000000, 
1.46439:0A000000, 1.115228:00000000, 0.104668:12000000
, 1.44903:25000000, 1.115228:00000000, 
12.56248:DC04000053656E64417320636865636B206661696C65642062656375617365204149206973206E756C6C0000,
 7.40748:010000000000010B01000000, 7.57132:00000000000000000F010480, 
4.39640:DC040000, 1.63016:32000000, 
8.45434:888C4079C982DB429564573D7EFC63AA38662D36, 0.104348:34393162, 5.4
6798:040000004D61696C4974656D5375626D697373696F6E00542031302E, 
7.51330:6E32E3BDC31EDF088F000100, 
5.10786:0000000031352E32312E303437322E3030353A595131505230314D4231313930323A64316565613638662D366634302D343931622D616435352D3430623034373664643163313A383338303A2E4E45542031302E302E313100000000,
 0.39570:00000000, 1.559
54:0B000000, 0.40818:02000000, 1.33010:0B000000, 2.54258:00000000, 
0.59634:02000000, 1.56562:00000000, 1.33010:0B000000, 2.54258:00000000, 
0.59634:00000000, 1.56562:00000000, 1.55954:0A000000, 1.33010:0A000000, 
2.54258:00000000, 0.40002:03000000, 1.56562:00000000, 1.33010:0A000000, 
2.54258:00000000, 0.40002:00000
000, 1.56562:00000000, 1.55954:0A000000, 1.33010:0A000000, 2.54258:00000000, 
0.40002:00000000, 1.56562:00000000, 1.33010:0A000000, 2.54258:00000000, 
0.40002:01000000, 1.56562:00000000, 1.64146:0E000000, 1.33010:0E000000, 
2.54258:00000000, 1.33010:0E000000, 2.54258:00000000, 1.64146:32000000, 
1.33010:32000000, 2.5
4258:DC040000, 1.33010:32000000, 2.54258:DC040000, 255.97900:00000000, 
4.120460:DC040000, 1.52466:02000000, 1.52466:02000000, 1.42738:09000000, 
0.37698:08000000, 1.42738:09000000, 0.37698:01000000, 1.52466:01000000, 
0.60402:33000000, 1.52466:01000000[EndDiagnosticData] 
[Hostname=YQ1PR01MB11902.CANPRD01.PROD.OUTLO
OK.COM]
2f15c431563c0591 mta error reason=Bad response: line too long
2f15c431563c0591 mta delivery evpid=ff8be9c9796c8290 
from=<[email protected]<mailto:[email protected]>>
 to=<[email protected]<mailto:[email protected]>> rcpt=<-> 
source="172.31.31.196" relay="52.96.157.114 (52.96.157.114)" delay=3m24s 
result="TempFail" stat="Bad response: line too long"
mproc: dispatcher -> control : 46 IMSG_STAT_DECREMENT
mproc: dispatcher -> control : 50 IMSG_STAT_DECREMENT
mproc: dispatcher -> control : 42 IMSG_STAT_DECREMENT
debug: mta: 0x28c3d5ef6d0: session done
mproc: dispatcher -> control : 45 IMSG_STAT_DECREMENT
debug: mta_route_collect([] <-> 52.96.157.114 (52.96.157.114))
debug: mta: connecting with 
[connector:[]->[relay:smtp.office365.com,port=25,smtp+tls,auth=secrets:o365_creds,mx],0x0]
debug: mta: no task for connector
debug: mta: mta_route_unref(): keeping route [] <-> 52.96.157.114 
(52.96.157.114) alive for 3s (imposed delay)
mproc: dispatcher -> queue : 41 IMSG_MTA_DELIVERY_TEMPFAIL
debug: mta: flush for ff8be9c9796c8290 (-> 
[email protected]<mailto:[email protected]>)



The error “Bad response: line too long” doesn’t appear in its entirety, so I’m 
grepping for partial hits.

My first thought was that insanely-long 554 error from O365 was tripping up 
smtpd, but looking at the code very early in smtp_client.c : 
smtp_client_readline, it looks like the “line too long” error is either being 
triggered by the *next* line, which is not logged anywhere, or by code 
elsewhere… but in any case params.linemax is set to 16k which surely would be 
enough for anything in use today?

My second thought is that the error is coming from util.c : 
parse_smtp_response, which is (perhaps erroneously?) comparing against LINE_MAX 
(i.e. 2048), instead of SMTP_LINE_MAX.

Ultimately, there are enough moving parts in the code base that I’m not really 
sure where it’s coming from.

It’s been forever since I last had to recompile bits of an OpenBSD system, but 
I’m pretty sure I remember how to if needed.

Any ideas?
-Adam Thompson
[email protected]<mailto:[email protected]>

Reply via email to