I have script which sends emails to multiple people. Sometimes it returns error so I want to try it 3 more times. If it's not successful in 3 attempts then returns error message. As of now I am using tryCatch() which returns message when error occurs in first attempt and skips to next recipient.
tryCatch({ CODE HERE }, error=function(e){
print("Email not sent")
})
CODE
library(blastula)
create_smtp_creds_file(
file = "gmail_secret",
user = "sender@email.com",
provider = "gmail"
)
email <- prepare_test_message()
email %>%
smtp_send(
from = "sender@email.com",
to = "recipient@email.com",
credentials = creds_file(
"gmail_secret")
)