Hi Mates ,As title say,could I receive two or three email account like a@a.com&b@b.com&c@c.com from one deployment Instance,Thank you for your reply
Hello,
Welcome to our support forum!
We have received your request and will get back to you shortly after reviewing it.
Thank you.
Hello @yuyan1988,
You can create up to three ImapClient instances to manage two or three email accounts simultaneously.
public final void testImapMultithread() throws InterruptedException {
GreenMail greenMail = new GreenMail(
new ServerSetup[]{
new ServerSetup(30000, "127.0.0.1", ServerSetup.PROTOCOL_IMAPS),
}
);
greenMail.start();
greenMail.setUser("test1@localhost", "123");
greenMail.setUser("test2@localhost", "123");
greenMail.setUser("test3@localhost", "123");
Thread.sleep(3000);
int threadsCount = 3;
ExecutorService es = Executors.newFixedThreadPool(threadsCount);
for (int i = 0; i < threadsCount; i++) {
final int threadIdx = i + 1;
es.submit(new Runnable() {
@Override
public void run() {
try {
try (ImapClient client = new ImapClient("127.0.0.1", 30000,
"test" + threadIdx + "@localhost", "123",
SecurityOptions.SSLImplicit)) {
client.setLogFileName("log-imap" + threadIdx);
Thread.sleep(new Random().nextInt(3000));
client.noop();
for (int j = 0; j < 10; j++) {
Thread.sleep(new Random().nextInt(3000));
client.appendMessage("INBOX", new MailMessage(
"test0@localhost", "test" + threadIdx + "@localhost", "subject " + j, "body"));
}
Thread.sleep(new Random().nextInt(3000));
Assert.assertEquals(10, client.listMessages().size());
}
} catch (Exception e) {
System.err.println(threadIdx + " ERROR " + e.getMessage());
}
}
});
}
es.shutdown();
es.awaitTermination(10, TimeUnit.MINUTES);
}
HI Sergey,thk u for your reply。
I saw your demo, I consider that one aspose.email Instance can only manage one email account ,include receive 、send and other operate,am I right ?
If I want use this plugin to manage more account like 1000 or 10000 , what could I do to fit the request
Hello @yuyan1988,
Each ImapClient instance can manage one email account at a time. This means you need to create multiple instances if you want to handle multiple accounts simultaneously.
In this case, you’ll need to use multithreading to manage multiple email accounts concurrently.
HI dmitry ,thank your reply
So I wana to have a question ,could we config a arraylist like accountList = {a,b,c,d…} ,then we could make instances from this configuration ,and we can listen those account’s event
You can use an ArrayList or any other collection to store account configurations and then create ImapClient instances from this list to manage multiple email accounts.
thank you mate , for I am in a strong security request company,So we have not download our product right now ,I should ask those technology question before our business talk, make sure whether our product could fit our request ,now I make sure it’s good enough !
You’re welcome! It’s perfectly fine to ask technical questions before business discussion to ensure that the product meets your needs. If you have any other questions, please feel free to ask.
Best regard!
Thank you very much.