'Blastula and render_email via docker cron container
I am having issue seeing and understanding an error via using the function render_email from the package blastula.
Below are an RMarkdown file and an R file I created to try debugging.
I am trying to send html emails automatically using blastula and crontab via a docker cron container.
Email is being sent when I run the script in Rstudio.
Email is being sent when I enter in the cron container and run /usr/local/bin/Rscript /home/Temp_Debug.R
I can also confirm that when I edit crontab inside cron container by doing crontab -e, and writing:
15 4 * * * /usr/local/bin/Rscript /home/Vente_Immo_Loop_Structure.R >> /home/cronlog_debug2022 || /home/cronlog_debug2022
this script starts because as an output in the log I see:
A - EMAIL
But then I assume it stops because nothing happens after that.
I am totally blind because I don't receive any error or nothing.
Any idea how I can debug this ?
RMarkdown file:
---
title: "Test_R"
output: blastula::blastula_email
---
```{r, echo=TRUE,message=TRUE, warning=TRUE, fig.keep='all'}
cat( 'RMARKDOWN \n')
Name <- c("Jon", "Bill", "Maria", "Ben", "Tina")
Age <- c(23, 41, 32, 58, 26)
df <- data.frame(Name, Age)
df
```
R file:
working_dir <- "/home"
setwd(working_dir)
library(blastula)
library(keyring)
library(readr)
library(plyr)
library(caTools)
library(bitops)
library(httr)
library(rvest)
library(curl)
library(dplyr)
library(stringr)
library(mailR)
library(xlsx)
library(knitr)
library(kableExtra)
library(rmarkdown)
library(data.table)
library(readxl)
library(writexl)
library(gsheet)
# Send new data by Email to Users
cat( 'A - EMAIL \n')
render_email("Test_RMarkdown.Rmd", quiet = FALSE)
cat( 'B - EMAIL \n')
email <- blastula::render_email("Test_RMarkdown.Rmd", quiet = FALSE)
cat( 'C - EMAIL \n')
email %>%
smtp_send(
to = "[email protected]",
from = c("Name" = "[email protected]"),
subject = "Title Test",
credentials = creds_file("gmail_app_pwd_creds")
)
cat( 'D - EMAIL \n')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
