I wrote a Service app in Delphi 10 that sends emails (either with or without attachment).
I use Indy 10.6.2.
this is the main code that sends the email
with FdmMSThread do
begin
// based on MailMessage.atachmentsCount set the conentytype
if MailMessage.MessageParts.Count > 0 then
MailMessage.ContentType := 'multipart/mixed'
else
MailMessage.ContentType := 'text/plain';
MailMessage.CharSet := 'UTF-8';
SMTP.Connect;
SMTP.Send(MailMessage);
end;
A customer reports that on his antivirus reports
X-Amavis-Alert: BADHEADER SECTION, MIME error:error: multipart boundary is missing, or contains CR or LF
All the headers are generated by Indy, and they should be fine, even because this application is in production since years.
I am not able to pinpoint the problem, could you please help? Where exactly the problem is?
I also tried to send a message to www.mail-tester.com but I got a score of 9/10, the only problem is related to the lack of a DKIM signature, but nothing about bad headers. So it seems to me that Amavis is quite picky.
What could be causing this error message?
How can I ensure that the multipart boundary in my emails is correctly formatted?
I paste here the full message, I hope you can help me.
Received: by mail-tester.com (Postfix, from userid 500)
id 47088A0BC2; Fri, 31 May 2024 10:37:29 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail-tester.com
X-Spam-Level:
X-Spam-Status: No/0.0/5.0
X-Spam-Test-Scores: SPF_HELO_NONE=0.001,SPF_PASS=-0.001
X-Spam-Last-External-IP: 151.80.13.250
X-Spam-Last-External-HELO: mail.mycompany.com
X-Spam-Last-External-rDNS: mail.mycompany.com
X-Spam-Date-of-Scan: Fri, 31 May 2024 10:37:29 +0200
X-Spam-Report:
* 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
* -0.0 SPF_PASS SPF: sender matches SPF record
Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=151.80.13.250; helo=mail.mycompany.com; [email protected]; [email protected]
DMARC-Filter: OpenDMARC Filter v1.3.1 mail-tester.com 5E01FA0BBB
Authentication-Results: mail-tester.com; dmarc=pass header.from=myproduct.com
Received: from mail.mycompany.com (mail.mycompany.com [151.80.13.250])
(using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail-tester.com (Postfix) with ESMTPS id 5E01FA0BBB
for <[email protected]>; Fri, 31 May 2024 10:37:26 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
by mail.mycompany.com (Postfix) with ESMTP id 16F0413B679
for <[email protected]>; Fri, 31 May 2024 08:37:26 +0000 (UTC)
Received: from mail.mycompany.com ([127.0.0.1])
by localhost (mail.mycompany.com [127.0.0.1]) (amavis, port 10032)
with ESMTP id Cv-T4Nz7lWnh for <[email protected]>;
Fri, 31 May 2024 08:37:25 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
by mail.mycompany.com (Postfix) with ESMTP id E01E413B698
for <[email protected]>; Fri, 31 May 2024 08:37:25 +0000 (UTC)
X-Virus-Scanned: amavis at mycompany.com
Received: from mail.mycompany.com ([127.0.0.1])
by localhost (mail.mycompany.com [127.0.0.1]) (amavis, port 10026)
with ESMTP id AoeOMfjMpxWI for <[email protected]>;
Fri, 31 May 2024 08:37:25 +0000 (UTC)
Received: from sql (unknown [193.38.133.50])
(using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.mycompany.com (Postfix) with ESMTPSA id 6648113B679
for <[email protected]>; Fri, 31 May 2024 08:37:25 +0000 (UTC)
From: "my self" <[email protected]>
Subject: P0401 Analisi del Contesto (Distribuzione Rev. 06)
To: [email protected]
Content-Type: multipart/mixed; charset=UTF-8; boundary="GY74iaF=_ueKJjxGVLnCDZedhRCs3hBylY"
MIME-Version: 1.0
Date: Fri, 31 May 2024 10:37:25 +0200
Message-Id: <[email protected]>
This is a multi-part message in MIME format
--GY74iaF=_ueKJjxGVLnCDZedhRCs3hBylY
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
THIS IS THE MESSAGE SUBJECT
-------------------------------------------------
This is the message body
-------------------------------------------------
--GY74iaF=_ueKJjxGVLnCDZedhRCs3hBylY
Content-Type: application/pdf;
name="attachmentName.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="attachmentName.pdf"
JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFu
ZyhpdC1JVCkgL1N0cnVjdFRyZWVSb290IDcwIDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4v
[...]
b3QgMSAwIFIvSW5mbyA4OTUgMCBSL0lEWzxDRTM4NTg4NkYxRUJFRjQzOUIxRjdFNEM3QzcxRkM5
Nz48Q0UzODU4ODZGMUVCRUY0MzlCMUY3RTRDN0M3MUZDOTc+XSAvUHJldiA2MDU2NjkvWFJlZlN0
bSA2MDM1MTM+Pg0Kc3RhcnR4cmVmDQo2MjQyMzANCiUlRU9G
--GY74iaF=_ueKJjxGVLnCDZedhRCs3hBylY--