Sending Authenticated Email
This is an analysis of what work would be needed to enable CSF-based apps to send authenticated email.
Changes to CSF:
1. Configuration of mailSender Spring Bean
Configure mailSender bean to use additional properties. Currently only uses "host" = "outgoing.mit.edu". This would be a modification to applicationContext-csf-email-scheduler.xml in the csf-email module. The additional properties are:
<bean id="mailSender"> <property name="host" value="outgoing.mit.edu"/> <property name="port" value="587"/> <property name="username" value="USERNAME"/> <property name="password" value="PASSWORD"/> <property name="javaMailProperties"> <props> <prop key="mail.debug">true</prop> <prop key="mail.smtp.auth">true</prop> <prop key="mail.smtp.starttls.enable">true</prop> </props> </property> </bean>
These property values should be externalized to a properties file. We can put these properties in machine.properties - apps should pick this up automatically. Only one copy of this props file per server.
Any app we need to use this feature would need to upgrade its version of CSF and be retested. Each app would also need to reviewed to make sure ist uses "machine.properties" in its property configuration.
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
My initial test does the latter, I think. WTW seems to do the former.
The former 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:
Get list of email events
DO FOR each email event
create MimeMessagePreparator
send message using MimeMessagePreparator
update email event
END DO
do this:
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