Site notification email (mail when a user is added to a site) is randomly missing. A given front end either works or doesn't work after a restart.
There's a backtrace
2009-07-07 08:52:12,354 WARN http-443-Processor73 org.sakaiproject.email.impl.BasicEmailService - Email.sendMail: exception: Sending fa\
iled;
nested exception is:
class javax.mail.AuthenticationFailedException
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:102)
at org.sakaiproject.email.impl.BasicEmailService.sendMessageAndLog(BasicEmailService.java:1081)
at org.sakaiproject.email.impl.BasicEmailService.sendMail(BasicEmailService.java:477)
at org.sakaiproject.email.impl.BasicEmailService.sendMail(BasicEmailService.java:285)
at org.sakaiproject.email.impl.BasicEmailService.send(BasicEmailService.java:546)
at org.sakaiproject.sitemanage.impl.UserNotificationProviderImpl.notifyAddedParticipant(UserNotificationProviderImpl.java:118)
Rsmart has a fix for 2.5.2 that their release notes say fixed AuthenticationFailedException. However there is no jira associated with it.
I fetched their 2.5.1 and 2.5.2 and diff'ed them. They changed
Session session = Session.getDefaultInstance(props, null);
to
Session session = Session.getInstance(props);
I am fairly sure that this is actually the fix. I used a JSP in the context of site-manage and checked the session returned by getDefaultInstance. It had properties that included mail.smtp.auth = true on once of the front ends where we were seeing the failure. Retting the properties in the default instance fixed things. This is going to be hard to test because it often doesn't fail. Here's the jsp I used to look around and also to reset the properties:
<%@ page import="javax.mail.Session" %>
<%@ page import="javax.mail.Transport" %>
<%@ page import="javax.mail.internet.InternetAddress" %>
<%@ page import="javax.mail.internet.MimeMessage" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Properties" %>
<%@ page import="org.sakaiproject.email.cover.EmailService" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "rulink.rutgers.edu");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.from", "
notifications@sakai.rutgers.edu");
Session s = Session.getDefaultInstance(props, null);
out.println(s.getProperties());
props = s.getProperties();
props.put("mail.smtp.host", "rulink.rutgers.edu");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", false);
props.put("mail.smtp.from", "
notifications@sakai.rutgers.edu");
Transport t = s.getTransport(new InternetAddress("
hedrick@rutgers.edu"));
out.println(t.getClass());
out.println(s.getProvider("smtp"));
%>
foo
Applied change as suggested.