gpt4 book ai didi

java - java中使用一个管理员帐户接收所有帐户的邮件

转载 作者:行者123 更新时间:2023-12-02 09:17:53 25 4
gpt4 key购买 nike

有没有什么方法可以与java一起使用来接收属于某个域[任何邮件帐户]@domain.com的所有电子邮件的所有电子邮件,而无需登录每个邮件帐户,而是通过使用一个管理员帐户登录。我不知道 Apache James 是否可以做到这一点?

最佳答案

您可以使用Retrofit在java中访问Apache James提供的REST API

对于 Apache James 看看 https://james.apache.org/server/manage-webadmin.html

更具体地说是“Listing mails contained in a mail repository”部分。

curl -XGET http://ip:port/mailRepositories/encodedPathOfTheRepository/mails

Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Example:

curl -XGET http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails The answer

will contains all mailKey contained in that repository.

[
"mail-key-1",
"mail-key-2",
"mail-key-3" ]

Note that this can be used to read mail details.

列出后,您可以得到read or download all the mail details

curl -XGET http://ip:port/mailRepositories/encodedPathOfTheRepository/mails/mailKey

Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Resource name mailKey should be the key of a mail stored in that repository. Example:

curl -XGET http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails/mail-key-1

If the Accept header in the request is “application/json”, then the response looks like:

{
"name": "mail-key-1",
"sender": "sender@domain.com",
"recipients": ["recipient1@domain.com", "recipient2@domain.com"],
"state": "address-error",
"error": "A small message explaining what happened to that mail...",
"remoteHost": "111.222.333.444",
"remoteAddr": "127.0.0.1",
"lastUpdated": null
}

If the Accept header in the request is “message/rfc822”, then the response will be the eml file itself.

Additional query parameter additionalFields add the existing informations to the response for the supported values: - attributes - headers - textBody - htmlBody - messageSize - perRecipientsHeaders

curl -XGET http://ip:port/mailRepositories/file%3A%2F%2Fvar%2Fmail%2Ferror%2F/mails/mail-key-1?

additionalFields=attributes,headers,textBody,htmlBody,messageSize,perRecipientsHeaders Give the following kind of response:

{
"name": "mail-key-1",
"sender": "sender@domain.com",
"recipients": ["recipient1@domain.com", "recipient2@domain.com"],
"state": "address-error",
"error": "A small message explaining what happened to that mail...",
"remoteHost": "111.222.333.444",
"remoteAddr": "127.0.0.1",
"lastUpdated": null,
"attributes": {
"name2": "value2",
"name1": "value1"
},
"perRecipientsHeaders": {
"third@party": {
"headerName1": [
"value1",
"value2"
],
"headerName2": [
"value3",
"value4"
]
}
},
"headers": {
"headerName4": [
"value6",
"value7"
],
"headerName3": [
"value5",
"value8"
]
},
"textBody": "My body!!",
"htmlBody": "My <em>body</em>!!",
"messageSize": 42424242
}

关于java - java中使用一个管理员帐户接收所有帐户的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58876114/

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