Skip to content

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

@hendr1km

Description

@hendr1km

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions