Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creds_envvar: Some variables need to be loaded with Sys.getenv from the .Renviron while others do not. #342

Open
hendr1km opened this issue Dec 9, 2024 · 0 comments

Comments

@hendr1km
Copy link

hendr1km commented Dec 9, 2024

When using the creds_envvar() function in smtp_send(), I noticed an inconsistency in how environment variables are handled:

  • For most parameters (e.g., user, host, port), I need to explicitly call Sys.getenv("VAR") to retrieve the values.
    
  • However, for the pass_envvar parameter, I must pass the name of the environment variable as a string (e.g., "SMTP_PASSWORD").
    

If I mistakenly use Sys.getenv("SMTP_PASSWORD") for pass_envvar, it results in an error indicating that the variable does not exist, even though it does.

This inconsistency is confusing and not well-documented in the package documentation. It would be helpful if either:

  • The documentation clearly explains this difference and provides examples.
    
  • The function is updated to support Sys.getenv("VAR") for pass_envvar, aligning it with the behavior for other parameters.
    

smtp_send(
email = email,
from = Sys.getenv("EMAIL_USER"),
to = participant_mail,
bcc = Sys.getenv("EMAIL_USER"),
subject = "Content",
credentials = creds_envvar(
user = Sys.getenv("EMAIL_USER"),
pass_envvar = "SMTP_PASSWORD", # Must be the name of the variable, not Sys.getenv()
host = Sys.getenv("SMTP_HOST"),
port = Sys.getenv("SMTP_PORT"),
use_ssl = TRUE
)
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant