3 Answers
3

In stead of sending mail to individual recipients, you should create a group for them first.
About the error you are getting, it seems like, you should allocate more memory to JVM(However that completely depends upon your requirements, project etc.., hence can't be the best solution).

On later on stage, you may consider to optimize the code to prevent memory related issues.

I think you are looping for number of recipients for the mail.So each time process of sending that mail is repeating. As I said earlier, You may send mail to all the recipients in one go by creating the group.
–
VedMay 4 '12 at 8:21

Most of the times, OutOfMemory errors can be solved by increasing heap size. But I would recommend that you do a performance analysis of your application, check if there are memory leaks or if you can (re)use some variables or memory.