I have a spring-stand alone application which uses simple spring email code as below , the to and the message is constructed using the values iter
to
message
Basically the answer is to not do this yourself.
Here is a very detailed reason why not: How to send 100,000 emails weekly?