Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to send email using mailR package

I am getting below mentioned error. I copied mail.jar, activation.jar, mailapi.jar, common-lang3.jar to /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext

java.lang.NoClassDefFoundError: javax/activation/DataHandler
    at org.apache.commons.mail.Email.createMimeMessage(Email.java:1832)
    at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1268)
    at org.apache.commons.mail.Email.send(Email.java:1436)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: java.lang.ClassNotFoundException
    at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 8 more
NULL
Error: NoClassDefFoundError (Java): javax/activation/DataHandler
like image 291
Sumit Chopra Avatar asked Apr 25 '18 07:04

Sumit Chopra


3 Answers

One of the comments in the link Vince Fulco provided works in Ubuntu 18.04: https://github.com/rpremraj/mailR/issues/77#issuecomment-465741847

Specifically:

  1. Download the following .jar files:

    • https://mvnrepository.com/artifact/javax.activation/javax.activation-api/1.2.0
    • https://mvnrepository.com/artifact/com.sun.activation/javax.activation/1.2.0
  2. Find out the java-mailR folder: system.file("java", package = "mailR")

    • In my case: "/home/MY_USERNAME/R/x86_64-pc-linux-gnu-library/3.5/mailR/java"
  3. Copy the two .jar files into that folder

Just in case, I rebooted the computer before trying it.

like image 175
Gorka Avatar answered Sep 24 '22 05:09

Gorka


This a well discussed and so far unresolved issue on github. https://github.com/rpremraj/mailR/issues/77

like image 32
Vince Fulco Avatar answered Sep 22 '22 05:09

Vince Fulco


Check your authentication credentials for SMTP. This error comes as a result of failure of authentication details

like image 23
RAJK Avatar answered Sep 22 '22 05:09

RAJK