Learn R Programming

blastula (version 0.3.5)

credential_helpers: Helpers for supplying SMTP credentials

Description

These helper functions, the credential helpers, are used to supply SMTP configuration and authorization information for the smtp_send() function. The creds_file(), creds_anonymous(), creds_key(), and creds() functions are to be used expressly with the credentials argument of smtp_send().

Usage

creds(user = NULL, provider = NULL, host = NULL, port = NULL, use_ssl = TRUE)

creds_anonymous(provider = NULL, host = NULL, port = NULL, use_ssl = TRUE)

creds_envvar( user = NULL, pass_envvar = "SMTP_PASSWORD", provider = NULL, host = NULL, port = NULL, use_ssl = TRUE )

creds_key(id)

creds_file(file)

Value

A credentials list object.

Arguments

user

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

provider

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 use SSL: supply a TRUE or FALSE value.

pass_envvar

The name of the environment variable that holds the value for an email account password. This is only used in the creds_envvar() credential helper function.

id

When using the creds_key() credential helper, the ID value of the key (in the system key-value store) needs to be given here. This was explicitly provided when using the create_smtp_creds_key() function (with its own id argument). To get an information table with all available blastula keys in the key-value store, we can use the view_credential_keys() function.

file

When using the creds_file() credential helper, we need to specify the location of the credential file, and, this is where that is done. The credential file was ideally generated by the create_smtp_creds_file() function.

Details

The creds() credential helper allows for manual specification of SMTP configuration and authentication.

The creds_anonymous() credential helper is similar to creds() but provides convenient defaults for authenticating anonymously with an SMTP server.

The creds_key() credential helper gets credentials stored in the system-wide key-value store. We can set that key and the credentials data using the create_smtp_creds_key() function.

The creds_file() credential helper is used to obtain credentials from a file stored on disk. We can create that file using the create_smtp_creds_file() function.

The creds_envvar() credential helper reads the password from the SMTP_PASSWORD environment variable (or an environment variable name that you specify). If using environment variables for other parameters, call Sys.getenv() manually (e.g. user = Sys.getenv("SMTP_USER")).