AnsweredAssumed Answered

Sending email in an Action

Question asked by mangar on Sep 7, 2010
Latest reply on Sep 8, 2010 by mangar
I am trying to send an email when a document is added to alfresco but the email address is NOT a user of alfresco.  I have made a custom action and it is triggered fine. However, when I try and send it through regular old java mail I get this error:

javax.mail.NoSuchProvidorException: smtp

here is the relevant code:
InternetAddress[] toAddrs = new InternetAddress[1];
toAddrs[0] = new InternetAddress(email);
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.localhost");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("AlfrescoEmail"));
msg.setRecipients(Message.RecipientType.TO,toAddrs);
msg.setText(userName+" has added a document. Enjoy.");
Transport.send(msg);

this code works fine outside of Alfresco.

The internet said that this happens when two different instances of javamail exist.  I assume that Alfresco has one.  Does anyone know how to send a custom email through alfresco? I cannot find an example anywhere. I found plenty of examples of how to setup Alfresco to mail stuff, but not on how to actually send a mail.

Thanks for any help.

Outcomes