简体   繁体   中英

Why does javamail API have an array of senders for messages?

i need to use some sort of a port to javaMail (link here ) that takes messages from an email server (gmail in my case, but might change in the future) , and reads some information from them.

one of the things i've noticed in the API is that getFrom method returns an array of Address objects , as shown here .

my question is : in which cases would this method return :

  1. null
  2. empty array
  3. more than 1 sender

?

all of my emails always had exactly one sender , no matter how weird it was sent (CC,BCC,forward,...) .

they say there "In certain implementations, this may be different from the entity that actually sent the message." , so how could i know for sure who sent the message, and if the current implementation is fine?

The frist two are DIRECTLY from the api:

(This attribute = the 'from' attribute of the email in question)

1) This method returns null if this attribute is not present in this message.

2) Returns an empty array if this attribute is present, but contains no addresses.

3) It checks the 'from' field of the email and returns an array of Address objects with one Address per entity found in that field. So, it will return an array of size > 1 when there is more than one 'sender' listed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM