2

I am trying to send an email from Rstudio by using mailR package but getting Error:

Error: EmailException (Java): Sending the email to the following server failed : smtp.gmail.com:465

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)

Code that I have tried:

mailR::send.mail(from = "xxxx@gmail.com",
          to = c("xxxx@gmail.com"),
          subject = "Test Email from R script",
          body = "Test email from R script by ViSa",
          # html = T,
          smtp = list(host.name = "smtp.gmail.com",
                    port = 465,
                    user.name = "xxxx@gmail.com",
                    passwd = "xxxx",
                    ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)

Saw some more SO post: Sending email in R getting Java error but it was suggested to use user name which I am already using but still getting this error.

Saw some videos/post about javax beans activation api etc... but there error was different. So do i need to install those.

Or what else should i do ?

Update:

I have restarted r session & ran again & now got this error :

org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com: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(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at RJavaTools.invokeMethod(RJavaTools.java:386) Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, 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.(Unknown Source) at sun.security.ssl.ClientHandshakeContext.(Unknown Source) at sun.security.ssl.TransportContext.kickstart(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 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.gmail.com:465

Now based on https://www.youtube.com/watch?v=QT51PX4o1qI

I 'av installed jar files from: https://mvnrepository.com/artifact/com.sun.activation/javax.activation/1.2.0

and

https://mvnrepository.com/artifact/javax.activation/javax.activation-api/1.2.0

and placed in C:\Program Files\R\R-4.1.0\library\mailR\java.

But I am still getting this error. Am i doing something wrong ?

ViSa
  • 1,563
  • 8
  • 30

0 Answers0