
Guide to Environment Variables for RPACT Cloud
12 November, 2025 11:49:46
Source:vignettes/guide-to-environment-variables.Rmd
guide-to-environment-variables.RmdThis guide explains the configuration of required and optional
environment variables for the RPACT Cloud application. Environment
variables can be defined in an .Renviron file to ensure
they are correctly loaded when the application starts. They are
particularly useful for deployment in Posit Connect.
General Environment Variables
ENV
- Description: The current environment of the application.
- Usage: Allows distinguishing between different environments, such as development and production.
- Validation: Optional. If set, it is included in the email subject.
-
Example:
ENV=production
SESSION_TIMEOUT_SECONDS
- Description: The session timeout duration in seconds.
- Usage: Specifies how long a session can be idle before it is terminated.
- Validation: Must be a non-empty string containing only digits. The value is converted to an integer.
-
Example:
SESSION_TIMEOUT_SECONDS=3600
MODULE_LOG_MESSAGES_ENABLED
- Description: Indicates whether the log messages module is enabled.
- Usage: Enables or disables the log messages module.
- Validation: Must be a non-empty string with a value of either TRUE or FALSE.
-
Example:
MODULE_LOG_MESSAGES_ENABLED=TRUE
LOG_LEVEL
- Description: The logging level of the application.
- Usage: Specifies the level of detail for log messages.
-
Validation: Must be one of the following values:
trace,debug,info,warn,error,disabled. -
Example:
LOG_LEVEL=info
MAIL_VALIDATION_REGEX
- Description: A regular expression for validating email addresses.
- Usage: Used to validate the recipient email address.
- Validation: Must be a valid regular expression. If not set, a default regular expression is used.
-
Example:
MAIL_VALIDATION_REGEX=@example\.com$
MAIL_FROM
- Description: The sender’s email address.
- Usage: Specifies the email address from which emails are sent.
- Validation: Must be a valid email address.
-
Example:
MAIL_FROM=noreply@example.com
MAIL_REPLY_TO
- Description: The reply-to email address.
- Usage: Specifies the email address to which replies should be sent.
- Validation: Must be a valid email address.
-
Example:
MAIL_REPLY_TO=support@example.com
SMTP-Specific Environment Variables
The following variables configure the SMTP server and are optional. If no SMTP data is defined, all emails will be sent via the Mailgun account of RPACT using the Mailgun RESTful API.
MAIL_SMTP_USER
- Description: The user name for the SMTP server.
- Usage: Used to authenticate with the SMTP server.
- Validation: Must be a non-empty string.
-
Example:
MAIL_SMTP_USER=my_smtp_user
MAIL_SMTP_PASSWORD
- Description: The password for the SMTP server.
- Usage: Used to authenticate with the SMTP server.
- Validation: Must be a non-empty string.
-
Example:
MAIL_SMTP_PASSWORD=my_smtp_password
MAIL_SMTP_HOST
- Description: The host name of the SMTP server.
- Usage: Specifies the server to connect to for sending emails.
- Validation: Must be a non-empty string.
-
Example:
MAIL_SMTP_HOST=smtp.example.com
MAIL_SMTP_PORT
- Description: The port number for the SMTP server.
- Usage: Specifies the port to connect to on the SMTP server.
- Validation: Must be a non-empty string containing only digits. The value is converted to an integer.
-
Example:
MAIL_SMTP_PORT=587
MAIL_SMTP_SSL_ENABLED
- Description: Indicates whether SSL is enabled for the SMTP connection.
- Usage: Determines if SSL should be used when connecting to the SMTP server.
- Validation: Must be a non-empty string with a value of either TRUE or FALSE.
-
Example:
MAIL_SMTP_SSL_ENABLED=TRUE
How to Define Environment Variables in Posit Connect Workbench
Click on Varibles in the top right corner of the Posit Connect Workbench:

Click in Add variable:

Specify Name and Value and click Save:

A reminder will be shown that you need to restart the application to apply the changes:

You can edit existing variables by clicking on the Edit button:

Change the value and click Save:

Finally click on Republish to apply the changes:

Publishing from the Command Line
You can also publish the application from the command line using the
rsconnect. The environment variables can be set following
these instructions: Environment
variables