-
Notifications
You must be signed in to change notification settings - Fork 0
/
OSFemail.R
57 lines (46 loc) · 1.69 KB
/
OSFemail.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Loop through CSV to submit emails for OSF / SPNHC
# install.packages("tinytex") # Need this for knitr / pdf_document
library("rmarkdown")
library("readr")
library("knitr")
library("rJava")
library("mailR")
# Prep EMails ####
# ...to loop thru sending emails:
# + subject = abstract title
# + attachment = PDF of title/author/abstract
# + body = abstract text
# Setup Notes: ####
#
# In your '.Renviron' file, add these lines:
# SENDER = "[email protected]"
# RECIP1 = "[email protected]"
# RECIP2 = "[email protected]"
# SENDPW = "your-email-password"
#
# In your gmail account, "allow less secure apps" - https://myaccount.google.com/lesssecureapps
#
sender <- Sys.getenv("SENDER")
recipients <- c(Sys.getenv("RECIP1"), Sys.getenv("RECIP2"))
password <- Sys.getenv("SENDPW")
for (i in 1:NROW(SPNHCform)) {
send.mail(from = sender,
to = recipients,
subject = SPNHCform$`Abstract Title`[i],
body = SPNHCform$`Abstract Text`[i],
encoding = "utf-8",
smtp = list(host.name = "smtp.gmail.com", # "aspmx.l.google.com", #
user.name = sender,
passwd = password,
ssl = T, # tls = T, #
port = 465), # 25),
authenticate = TRUE,
send = TRUE,
attach.files = c(paste0("./output/",
SPNHCform$PDFname[i], "_",
"2019SPNHCabstract_", i, ".pdf")),
file.descriptions = c("Abstract PDF"), # optional parameter
debug = TRUE)
print(i)
Sys.sleep(10)
}