为什么Message.getFrom()方法返回一个Array?

为什么Message.getFrom()方法返回一个Array?

问题描述:

了JavaMail API有具有GETFROM()梅索德按摩类,你可以在这里找到:为什么Message.getFrom()方法返回一个Array?

  1. 为什么它返回一个数组:

    有关此方法

    https://javamail.java.net/nonav/docs/api/javax/mail/Message.html#getFrom()

    两个问题Address对象而不是一个Address对象?我想不到一个消息是由多个发件人发送的情况。

  2. 该文档说明它可能与实际发送消息的实体不同,在某些实现中。有没有这种实现的例子?
+1

我不知道他们的意思是这样,但如果你是锻造消息发送,你放什么消息的发送者头很可能是与您用作SMTP凭据或“MAIL FROM”命令不同),因此创建类似于您的问题#2的情况。 – GPI 2014-10-27 08:50:15

在标准RFC 5322 SMTP允许多个FROM地址

3.6.2。发起者字段

消息的发起者字段由发件人字段,发件人字段(如果适用)和可选的回复字段组成。 from字段由字段名称“From”和一个或多个邮箱规范的逗号分隔列表组成。如果发件人字段在邮箱列表中包含多个邮箱规范,则必须在邮件中显示包含字段名称“发件人”和单个邮箱规范的发件人字段。在任何一种情况下,还可以包含可选的回复字段,其中包含字段名称“Reply-To”和一个或多个地址的逗号分隔列表。

从= “从:” 邮箱列表CRLF

看看迈克尔·汉普顿的回答这个serverfault问题:SMTP allows for multiple from addresses. Was this ever useful, why does this exist?

正如他在他的回答中提到:

RFC 822实际上给出了这种用法的一个例子。它使用时需要 发件人:标题。

 

A.2.7。代理委员会的成员

  George's secretary sends out a message which was authored 
    jointly by all the members of a committee. Note that the name 
    of the committee cannot be specified, since <group> names are 
    not permitted in the From field. 

     From: [email protected], 
       [email protected], 
       [email protected] 
     Sender: [email protected]