blastula
blastula copied to clipboard
Where to set password argument?
I don't understand how can I send an email with the password? I don't want to enter it manually. Functions creds
and create_smtp_creds_file
doesn't have password argument.
I would like to schedule my script on windows, so mannualy enetering the password is not the solution.
You can set an environment variable with Sys.setenv("SMTP_PASSWORD"="1234") and use creds_envvar function.
I add this line on the beggining of the script, but it still asks me for password when I want to send e-mail.
@felipeangelimvieira , it still ask me for password, even if I add Sys.setenv("SMTP_PASSWORD"="xxx") to the script
@MislavSag a better way to set an environment variable with R is by putting it in your .Renviron
file. It's really easy to open with usethis::edit_r_environ()
. Once you're in the file, add the line SMTP_PASSWORD={password}
.
The creds_envvar()
function needs to be used at the credentials
argument of smtp_send()
. Like this (if you are using Gmail):
prepare_test_message() %>%
smtp_send(
from = "[email protected]",
to = "[email protected]",
subject = "The Subject",
credentials = creds_envvar(
user = "username",
pass_envvar = "SMTP_PASSWORD",
provider = "gmail"
)
)
Hope this helps.