Hello, for what i searched there was this module(“Messaging Module”) that is on beta and didnt receive any update since 3 or 4 years ago.
I checked through this link, but no idea how that module works…
Any suggestions on how to send an email through Java/ using other module ?
OpenMRS core has a messaging service that should be able to send email, there is SMTP related global properties you’d need to set to make it work, don’t know anyone that has been able to use it though.
@dkayiwa I tried using the same code from Reporting omod as indicated above for sending email.
I am getting the following class cast exception error, which I think maybe due to classloader issues.
Caused by: java.lang.ClassCastException: com.sun.mail.handlers.text_plain cannot be cast to javax.activation.DataContentHandler
at javax.activation.MailcapCommandMap.getDataContentHandler(Unknown Source)
at javax.activation.MailcapCommandMap.createDataContentHandler(Unknown Source)
at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:261)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1321)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1030)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:416)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1307)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2074)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)
at javax.mail.Transport.send(Transport.java:117)
Strange because i just copied and pasted your code in an existing reference application module and it worked. I run the code in the Activator.started() call back as below:
DefaultMailSender sender = new DefaultMailSender();
sender.send()
Probably it is something to do with the modules in your environment? What is the simplest way of reproducing it without having to load bahmni?
Got it. I am getting other error while connecting to SMTP server, but thats different issue.
So, I started checking other omods and dependencies. Turns out one of the modules were loading up commons-email which I assume uses javax.mail. Unloaded the other module and restart did the job.
Thanks for the help. Let me try to resolve the next steps