...
2. One question - for a bulk email send, should the sequence be:
authenticate to server
DO FOR EACH MAIL MESSAGE
send email message
END DO
or
DO FOR EACH MAIL MESSAGE
authenticate to server
send email message
END DO
we authenticate to the server for every single email message in the batch:
Code Block |
---|
DO FOR EACH MAIL MESSAGE
authenticate to server send email message
END DO
|
or just once for the batch:
Code Block |
---|
authenticate to serverDO FOR EACH MAIL MESSAGE
send email message
END DO
|
My initial test with CSF does the formerMy initial test does the latter, I think. WTW seems to do the formerlatter.
The former latter seems better (only one login per batch rather than one login per message). To do this, the email service needs to change - in fact it may be better to change it anyway. In "batchSend", instead of:
Code Block |
---|
Get list of email events |
...
DO FOR each email event |
...
create MimeMessagePreparator |
...
send message using MimeMessagePreparator |
...
update email event |
...
END DO |
do this:
Code Block |
---|
Get list of email events |
...
DO FOR each email event |
...
create MimeMessagePreparator and store in list |
...
END DO |
...
send messages using list of MimeMessagePreparators |
...
update email events |
We would use the "batch" API of Spring's JavaMailSender API:
Code Block |
---|
send(MimeMessagePreparator[] mimeMessagePreparators)
|
instead of
Code Block |
---|
send(MimeMessagePreparator mimeMessagePreparator)
|