Reputation: 385
I have to send bulk email through java SMTP. Currently I send email synchronously which is taking a lot of time and since every email provider have their per hour limit, so I have to sleep thread to avoid limitation.
What will be the best approach to send email Asynchronously without violating limitation using SMTP.
Thanks in advance.
Upvotes: 2
Views: 1218
Reputation: 8401
You should be able to send mails asynchronously running a new thread or using executor service.
But since you need capability to throttle outgoing mails you need a store and forward mechanism. Ideal solution would be using a queue where mesages can be posted. And then there should be a queue consumer which will be responsible for reading from the queue and sending the actual mail.
Upvotes: 1