Question

I have a application that sends an email through Play MVC mailer plugin, while register and Forgot password. I need to know how to send bulk email using the same plugin. That is I need to send email to all user when the new user is registered.

Here the Code I am using to send an email:

 setSubject("Confirm Registration");
 addRecipient(ua.username);
 setFrom("support@xxxx.com");
 send(ua, user);

Here I need to know how to add multiple Recipient and send an email?

Was it helpful?

Solution

That's easy. You can just call addRecipient multiple times to add more recipients. Or you can pass multiple recipients to it, like this:

addRecipient("alice@example.com", "bob@example.com", "charlie@example.com");

Or you can pass an array to addRecipient:

String[] rcpts = new String[] {"alice@example.com", "bob@example.com"};
addRecipient(rcpts);

Or you can take a List, make an array from it, and then pass it:

List<String> rcptsList = new ArrayList<String>();
rcptsList.add("alice@example.com");
rcptsList.add("bob@example.com");
addRecipient(rcptsList.toArray(new String[rcptsList.size()]));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top