Correctly parse Exim 4.99 received lines
bz #8365


git-svn-id: https://svn.apache.org/repos/asf/spamassassin/trunk@1937482 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/Mail/SpamAssassin/Message/Metadata/Received.pm b/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
index ee0a9c9..d1c26b9 100644
--- a/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
+++ b/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
@@ -409,6 +409,15 @@
   if (/ by / && / with .{0,64}((?:ES|L|UTF8S|UTF8L)MTPS?A|ASMTP|HTTP[SU]?)(?: |;|$)/i) {
     $auth = $1;
   }
+
+  # Exim 4.99 and later can be configured to report a non-standard protocol
+  # when TLS is negotiated on connection rather than with STARTTLS. (It is
+  # mostly intended for logging purposes, but it bleeds through into headers.)
+  # Recognize this and treat as if using the standard protocol designator.
+  elsif (/ by / && / with ESSMTPA(?:\s|;|$)/i) {
+    $auth = 'esmtpsa';
+  }
+
   # GMail should use ESMTPSA to indicate that it is in fact authenticated,
   # but doesn't.
   elsif (/ by mx\.google\.com with ESMTPS id [a-z0-9]{1,4}sm[0-9]{2,9}[a-z]{3}\.[0-9]{1,3}\.[0-9]{4}\.(?:[0-6][0-9]\.){4}[0-6][0-9]/ && /\(version=([^ ]+) cipher=([^\)]+)\)/ ) {
diff --git a/t/rcvd_parser.t b/t/rcvd_parser.t
index f4066ee..991fee5 100755
--- a/t/rcvd_parser.t
+++ b/t/rcvd_parser.t
@@ -2,7 +2,7 @@
 
 use lib '.'; use lib 't';
 use SATest; sa_t_init("rcvd_parser");
-use Test::More tests => 150;
+use Test::More tests => 151;
 use strict;
 
 # format is:
@@ -474,6 +474,9 @@
   'from cold-email.sendkit-mail.com (static.25.190.130.94.clients.your-server.de. [94.130.190.25]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59e0748994bsm1467533e87.36.2026.01.29.16.59.37 for <test@example.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 16:59:38 -0800 (PST)' =>
   '[ ip=94.130.190.25 rdns=static.25.190.130.94.clients.your-server.de helo=cold-email.sendkit-mail.com by=smtp.gmail.com ident= envfrom= id=2adb3069b0e04-59e0748994bsm1467533e87.36.2026.01.29.16.59.37 auth=ESMTPSA msa=0 ]',
 
+  'from 192-0-2-1.isp.example ([192.0.2.1]:43502 helo=ehlo.thunderbird.net) by mail.customer.example with essmtpa  (TLS1.3) tls TLS_AES_128_GCM_SHA256 (Exim 4.99.1) (envelope-from <customer@customer.example>) id 1vfyfh-000000085oY-23Kr for mailbox@external.example; Wed, 14 Jan 2026 11:04:20 +0000' =>
+  '[ ip=192.0.2.1 rdns=192-0-2-1.isp.example helo=ehlo.thunderbird.net by=mail.customer.example ident= envfrom=customer@customer.example intl=0 id=1vfyfh-000000085oY-23Kr auth=esmtpsa msa=0 ]',
+
 );
 
 my $sa = create_saobj();