How to send an email to multiple recipients in Spring

前端 未结 8 2228
花落未央
花落未央 2021-02-12 10:48

The email gets sents only to the last email address in the String[] to array. I\'m intending to send to all email addresses added to the array. How can I make that

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-12 11:26

    I think better approach is to declare "to" attribute as array in spring.xml file , pass values and use method setTo(string[]) as suggested by Deinum in comment. Process is define 'to' in xml file as

    
        
        abc@gmail.com
        xyz@gmail.com
        
    
    

    Now generate getter setter method for this array containing address of multiple recipient and pass it to setTo(String[]) method as :-

    helper.setTo(to);
    

提交回复
热议问题