You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Amavis报BAD HEADER SECTION:Delphi+Indy邮件MIME错误排查求助

邮件发送触发Amavis边界错误排查求助

我用Delphi 10结合Indy 10.6.2开发了一款支持带附件/无附件发送的邮件服务应用,核心发送代码如下:

with FdmMSThread do
  begin
// 根据MailMessage.atachmentsCount设置内容类型
    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;

客户反馈其杀毒软件触发Amavis警报:

X-Amavis-Alert: BADHEADER SECTION, MIME error:error: multipart boundary is missing, or contains CR or LF

该应用已上线多年,此前从未出现此类问题,所有邮件头均由Indy自动生成。我无法定位问题根源,特求助:

我曾向www.mail-tester.com发送测试邮件,得分9/10,仅提示缺少DKIM签名,未报头部错误,因此推测Amavis的校验标准更为严格。

请问:

  • 该错误的成因可能是什么?
  • 如何确保邮件中的multipart boundary格式正确?

附完整邮件内容:

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; envelope-from=noreply@myproduct.com; receiver=test-z469empbz@srv1.mail-tester.com 
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 <test-z469empbz@srv1.mail-tester.com>; 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 <test-z469empbz@srv1.mail-tester.com>; 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 <test-z469empbz@srv1.mail-tester.com>;
 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 <test-z469empbz@srv1.mail-tester.com>; 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 <test-z469empbz@srv1.mail-tester.com>;
 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 <test-z469empbz@srv1.mail-tester.com>; Fri, 31 May 2024 08:37:25 +0000 (UTC)
From: "my self" <noreply@mycompany.com>
Subject: P0401 Analisi del Contesto (Distribuzione Rev. 06)
To: test-z469empbz@srv1.mail-tester.com
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: <20240531083725.6648113B679@mail.my.company>

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--

内容的提问来源于stack exchange,提问作者UnDiUdin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 03:29:51