1

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?

4

1 回答 1

2

这很容易。您可以addRecipient多次调用以添加更多收件人。或者您可以将多个收件人传递给它,如下所示:

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

或者您可以将数组传递给addRecipient

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

或者你可以取 a List,从中创建一个数组,然后传递它:

List<String> rcptsList = new ArrayList<String>();
rcptsList.add("alice@example.com");
rcptsList.add("bob@example.com");
addRecipient(rcptsList.toArray(new String[rcptsList.size()]));
于 2013-07-18T11:00:56.163 回答