質問

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?

役に立ちましたか?

解決

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()]));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top