create_smtp_creds_key: Store SMTP credentials in the system's key-value store

View source: R/create_credentials.R

create_smtp_creds_keyR Documentation

Store SMTP credentials in the system's key-value store


We can set SMTP access credentials in the system-wide key-value store for the purpose of more easily sending email messages through smtp_send(). With this key added, the credentials helper creds_key() can be used in the credentials argument of smtp_send() (the id value is used to unambiguously refer to each key).


  user = NULL,
  provider = NULL,
  host = NULL,
  port = NULL,
  use_ssl = NULL,
  overwrite = FALSE



An identifying label for the keyname. The full key name is constructed in the following way: ⁠blastula-v1-<id>⁠. This id value is what's needed later to either use the key with creds_key(), or, delete the key with delete_credential_key(). A single, non-NA character, numeric, or integer value can be supplied here; the id will be coerced to a character value. If the id is supplied as a single character value, it cannot be an empty string and it cannot include hyphen characters.


The username for the email account. Typically, this is the email address associated with the account.


An optional email provider shortname for autocompleting SMTP configuration details (the host, port, use_ssl options). Options currently include gmail, outlook, and office365. If nothing is provided then values for host, port, and use_ssl are expected.

host, port, use_ssl

Configuration info for the SMTP server. The host and port parameters are the address and port for the SMTP server. use_ssl is an option as to whether to allow the use of STARTTLS, if available: it should be TRUE unless you have a specific reason to set it to FALSE.


An option that controls the overwriting of existing keys with the same id value. By default, this is FALSE (where overwriting is prohibited).


Support for setting keys through create_smtp_creds_key() is provided through the keyring package. This function cannot be used without that package being available on the system. We can use install.packages("keyring") to install keyring.


# Store SMTP credentials using the
# system's secure key-value store to
# make it much easier to send email
# out through Gmail with `smtp_send()`;
# provide the `id` of "gmail_creds"

# create_smtp_creds_key(
#   id = "gmail_creds",
#   provider = "gmail",
#   user = "",
#   )

blastula documentation built on Sept. 24, 2023, 1:07 a.m.