r Blastula smtp_server Gmail Login denied

285 Views Asked by At

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 = "[email protected]",
  host = "smtp.gmail.com",
  port = 465,
  use_ssl = TRUE
)

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

email %>%
  smtp_send(
    to = c("[email protected]"),    
    from = c("Your Newsletter" = "[email protected]"),
    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?

0

There are 0 best solutions below