Package edu.uiuc.ncsa.security.servlet.mail
This package is used for adding email notification support to Tomcat servlets.
Since Tomcat has a global facility for sending email, it is necessary to utilize that
rather than just rolling our own (or there will be runtime issues). This is a wrapper
for Java Mail.
Configuring Tomcat
- You must download a copy of the JavaMail jar and drop it into the $CATALINA_HOME/lib directory.
- You must add the following line to $CATALINA_HOME/context.xml
<Resource name="mail/Session" type="javax.mail.Session" auth="Container"/>
Optionally, you made add the switchmail.debug="true"
to this if you want to see lots of information about sending messages in the log file. You can also just put this switch in your properties file too (no quotes). - You must edit and setup your template files. This ensures that you have the ability to get the right message as needed.
-
Finally, in your deployment descriptor ("web.xml") file you must add the following section
(right before the final closing tag is fine):
<resource-ref> <description> Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server. </description> <res-ref-name>mail/Session</res-ref-name> <res-type>javax.mail.Session</res-type> <res-auth>Container</res-auth> </resource-ref>
One issue is that Tomcat uses multiple class loaders, so that if you include Java Mail in your
webapp you will ge very strange ClassCastExceptions, e.g.
javax.mail.Session cannot be cast to javax.mail.Session
This is because classes themselves exist as objects different class loaders
have different instances of them, hence they are not identical so cannot be cast
to each other. Rather than have a massive kludge to let you add the mail jar to your
webapp, we'll require that you use Tomcat's system for this.
-
Class Summary Class Description ServletMailUtil Note this is used in OA4MP and CILogon.ServletMailUtilProvider Created by Jeff Gaynor
on 6/25/13 at 11:01 AM