gpt4 book ai didi

java - 如何控制邮件标题的对齐方式?

转载 作者:行者123 更新时间:2023-11-30 04:53:04 26 4
gpt4 key购买 nike

我遇到一种情况,当我发送一封电子邮件主题超过80个字符时,有时电子邮件主题会插入一个“制表符”字符。我检查无效电子邮件的邮件标题,它们是对齐的,如果邮件标题条目超过 80 个字符,它将换行到新行,并插入“制表符”。我不知道哪个配置控制它,javaMail设置? SMTP 设置?

示例标题:

情况一:电子邮件主题无效,插入了字符“制表符”。

Received: from as09.aaaaaaaaa.com ([192.168.1.129]) by aaaaaaaaa.com
([192.168.1.49]) with ESMTP (TREND IMSS SMTP Service 7.0; TLS:
TLSv1/SSLv3,168bits,DES-CBC3-SHA) id ba8afe04001a23ba ; Wed, 1 Feb 2012
16:17:10 +0800
Received: from as09 (localhost [127.0.0.1])by as09.aaaaaaaaa.com
(8.13.8+Sun/8.13.8) with ESMTP id q118HAgi021891;Wed, 1 Feb 2012 16:17:10
+0800 (HKT)
Message-ID: <25866052.1328084230581.JavaMail.oracle@as09>
Date: Wed, 1 Feb 2012 08:17:10 +0000
From: <sss@abc.com>
To: ben@abc.com,
john@abc.com,
jimmy@abc.com
Subject: test Daily report for city pairs of iPhone App enquiries indocument
version Demo Customer/Test/Test/123/1231
CC: sam@abc.com
MIME-Version: 1.0

情况二:有效的电子邮件主题,刚刚换行

Received: from as08.aaaaaaaaa.com ([192.168.1.104]) by aaaaaaaaa.com
([192.168.1.49]) with ESMTP (TREND IMSS SMTP Service 7.0; TLS:
TLSv1/SSLv3,168bits,DES-CBC3-SHA) id c356e969001b37a5 ; Fri, 3 Feb 2012
09:16:58 +0800
Received: from as08.aaaaaaaaa.com (localhost [127.0.0.1]) by
as08.aaaaaaaaa.com (8.13.4+Sun/8.13.4) with ESMTP id q131Gw1l006160; Fri, 3
Feb 2012 09:16:58 +0800 (HKT)
Message-ID: <17351450.1328231818282.JavaMail.oracle@as08.aaaaaaaaa.com>
Date: Fri, 3 Feb 2012 01:16:58 +0000
From: <sss@abc.com>
To: ben@abc.com
Subject: test Daily report for city pairs of iPhone App enquiries in
document version Demo Customer/Test/Test/123/1231
CC: sam@abc.com

示例java代码:

public void sendEmail(Request req) throws Exception {
Session mailSession;
MimeMessage msg;
Properties mailSessionProp = new Properties();
mailSessionProp.put("mail.smtp.host", "localhost");
mailSessionProp.put("mail.smtp.port", "25");

mailSession = Session.getInstance(mailSessionProp, null);
msg = new MimeMessage(mailSession);
msg.addRecipients("TO", InternetAddress.parse(req.getRecipientAddress()));
msg.setSubject(MimeUtility.encodeText(req.getSubject(), "UTF-8", "B"));
msg.setHeader("X-Mailer", "");
msg.setSentDate(new Date());
msg.setContent(req.getMessage(), req.getMessageContentType().getType());
Transport.send(msg);
}

JavaMail:

    Manifest-Version: 1.0
Implementation-Version: 1.3.3_01
Specification-Title: JavaMail(TM) API Design Specification
Specification-Version: 1.3
Extension-Name: javax.mail
Created-By: 1.3.1 (Sun Microsystems Inc.)
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc.
Specification-Vendor: Sun Microsystems, Inc.
SCCS-ID: @(#)javamail.mf 1.5 02/03/14

最佳答案

根据http://www.faqs.org/rfcs/rfc2822.html,此行为是正确的

2.2.3. Long Header Fields

Each header field is logically a single line of characters comprising the field name, the colon, and the field body. For convenience however, and to deal with the 998/78 character limitations per line, the field body portion of a header field can be split into a multiple line representation; this is called "folding". The general rule is that wherever this standard allows for folding white space (not simply WSP characters), a CRLF may be inserted before any WSP.

关于java - 如何控制邮件标题的对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9441444/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com