4

I am running into an issue with blastula email and SMTP Gmail. When I run the following code on my local RStudio, it runs perfectly well and the email is sent.

library(blastula)

# To store my credentials with pwd in a file
create_smtp_creds_file(
  file = "gmail_creds",
  user = "myemail@gmail.com",
  host = "smtp.gmail.com",
  port = 465,
  use_ssl = TRUE
)

email <- blastula::render_email("RMarkdown_Template.Rmd")

email %>%
  smtp_send(
    to = c("myother@email.com"),    
    from = c("Your Newsletter" = "myemail@gmail.com"),
    subject = "Daily Newsletter",
    credentials = creds_file("gmail_creds")
  )

But when I run this exact same code on my RStudio on an ec2 instance, I get the following error message and the email is not sent:

Error in curl_fetch_memory(smtp_server, handle = h) : Login denied

FYI I activated the 'Less secure app' on the Gmail side.
Any idea where this problem come from?

ML_Enthousiast
  • 1,147
  • 1
  • 15
  • 39
  • Did you ever solve this issue? I am having the same problem now on an R script I have been running for several years and cannot resolve it. – reidj Jun 10 '22 at 17:23

0 Answers0