I have been working on trying to send emails from R using a gmail address, but I always get the same error code. Is there a way correcting this error. I know similar question have been asked before, but I can't get to figure it out with these answers. Thank you for your help
Also, the parameters from my google account already been adjusted.
Here is my code to send email:
library(mailR)
sender <- "abc@gmail.com"
recipients <- c("abc@gmail.com")
send.mail(from = sender,
to = recipients,
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "abc@gmail.com",
passwd = "123abc", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
Here is the error code
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:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 8 more
NULL
NoClassDefFoundError (Java): javax/activation/DataHandler[1] "Java-Object{org.apache.commons.mail.SimpleEmail@1ed6993a}"
>
Since Java 9 released javax.activation
had removed. So if you need to use Java 9 or above just install these jars
system.file("java", package = "mailR")
folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.