blastula icon indicating copy to clipboard operation
blastula copied to clipboard

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

Open hendr1km opened this issue 1 year ago • 0 comments

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 ) )

hendr1km avatar Dec 09 '24 21:12 hendr1km