1
library("mailR")
library(xlsxjars)
library(xlsx)

recipients<- c("receiver@gmail.com")
send.mail(from = "sender@gmail.com",
          to = recipients,
          subject = "Fraud Detection",
          body = "Your credit has been compromised .Please contact your bank.",
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "user@gmail.com", passwd = "********", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE,
          # optional parameter
          debug = TRUE)

I am trying this code.But i get following error(I have tried both formats using authentication and also without) and also I have turned on less secure apps on my gmail

DEBUG SMTP: Found extension "SIZE", arg "35882577" DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH" DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg "" DEBUG SMTP: Found extension "PIPELINING", arg "" DEBUG SMTP: Found extension "CHUNKING", arg "" DEBUG SMTP: Found extension "SMTPUTF8", arg "" DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM DEBUG SMTP: AUTH LOGIN command trace suppressed DEBUG SMTP: AUTH LOGIN failed 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(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.AuthenticationFailedException: 534-5.7.14

0 Answers0