I'm using mailR
for sending emails from within R
. This used to work just fine on other machines. That was before my Mac Mini. I can run install.packages(c("rJava", "mailR"))
without any problems. However when sending, I run into errors that (based on what has been asked before) seem to be related to Java.
Here is my code:
library(rJava)
library(mailR)
smtp_list = list(host.name = "smtp.sendgrid.net",
port = 587,
user.name = "XXX",
passwd = "XXX",
ssl = T)
body_html_test <- "<html><meta charset='UTF-8'><p>Hello<p></html>"
send.mail(from = "some@adress.com",
to = "my@adress.com",
subject = "This is a test",
body = body_html_test,
encoding="utf-8",
html = TRUE,
smtp = smtp_list,
authenticate = TRUE,
send = TRUE)
NULL
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.sendgrid.net:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.sendgrid.net, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2055)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
at javax.mail.Service.connect(Service.java:386)
at javax.mail.Service.connect(Service.java:245)
at javax.mail.Service.connect(Service.java:194)
at javax.mail.Transport.send0(Transport.java:253)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
... 6 more
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171)
at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:101)
at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:215)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
... 13 more
Error: EmailException (Java): Sending the email to the following server failed : smtp.sendgrid.net:465
At first I was inclined to believe that this has to do with my mailclient but based on what others have asked, this seems to be related to java
. The fact that this script runs smoothly on other machines points into that direction as well.
OS version:
$ sw_vers
ProductName: macOS
ProductVersion: 11.2
BuildVersion: 20D64
Java version:
$ java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
R version:
$ R
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
R Java configuration:
$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_291
Java home path : /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" - DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
^~~~~~~
1 error generated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
Thanks in advance for help.