How to send an email to multiple recipients in Spring

You have the choice to use the following 4 methods. I have provided examples of the two methods useful in this case. I have consolidated this information from the commentators below.

helper.setTo(InternetAddress.parse("[email protected],[email protected]"))
helper.setTo(new String[]{"[email protected]", "[email protected]"});

From the Javadoc:

enter image description here


The better approach is to create an array containing the address of multiple recipients.

    MimeMessageHelper helper = new MimeMessageHelper( message, true );
    helper.setTo( String[] to );

Tags:

Java

Email

Spring