Reputation: 1098
Is there any way that can be used with java to receive all emails of all emails belonging to a domain [any mail account]@domain.com
without logging in to each mail account, but by using one admin account to login.
I don't know if this is possible with Apache James?
Upvotes: 0
Views: 66
Reputation: 13545
you can use Retrofit in java to access the REST API provided by Apache James
for Apache James look at https://james.apache.org/server/manage-webadmin.html
more specifically the part on "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.
After listing, you can get then 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": "[email protected]", "recipients": ["[email protected]", "[email protected]"], "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": "[email protected]", "recipients": ["[email protected]", "[email protected]"], "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 }
Upvotes: 1
Reputation: 76
You can you Java Mail API for this, then you can check the domaine using java code.
Upvotes: 0