Customizing "From" addresses for email reports sent by RStudio Connect

Follow

Sometimes it is desirable for emailed reports sent by RStudio Connect to appear as if they were
sent by the content owner instead of the system email address configured by Server.SenderEmail.  This is made possible by the Server.EmailFromUserAddresses setting, however, this does require additional steps by your email administrator.  This article describes one possible configuration which utilizes Google Workspace as the SMTP provider.

 

First, create an SMTP Relay through the Google admin console:

  • Navigate to Apps > Google Workspace > Gmail > Advanced Settings.
  • Configure your SMTP relay service settings:
    • From the 1. Allowed senders drop-down, select Only addresses in my domains.
    • In the Authentication section, select the Require SMTP Authentication check box.
    • In the Encryption section, select the Require TLS encryption check box.
    • Click Save.

Screen_Shot_2021-06-17_at_10.55.51_AM.png

 

Next, enable "Mail delegation" for your organization's domain:

  • Navigate to Apps > Google Workspace > Gmail > User Settings.
  • In the Mail delegation pane, select the following:
    • Let users delegate access to their mailbox to other users in the domain.
    • Show the account owner and the delegate who sent the email.

Screen_Shot_2021-06-17_at_11.04.28_AM.png

 

Create a user account for sending system emails from RStudio Connect:

  • Navigate to Users and click Add a user.

Screen_Shot_2021-06-17_at_11.16.23_AM.png

  • Fill out the required fields and click Add a new user to save your changes.

add-user.png

 

Sign into the new user account created in the previous step.

Then, enable 2-step-verification and click App passwords to create a new App Password for RStudio Connect to use later. 

 

Screen_Shot_2021-06-17_at_11.36.06_AM.png

When creating the App Password, click the Select device drop-down and select the option Other (Custom name).

select-device.png

Type a name for the device and click Generate.

Screen_Shot_2021-06-17_at_11.40.25_AM.png

 

Add the following configurations to RStudio Connect's main configuration file (rstudio-connect.gcfg):

IMPORTANT NOTE: Make sure to update the specified values in the configuration below before restarting Connect.
[SMTP]
Host = "smtp-relay.gmail.com"
Port = 465
SSL = true

; Replace this value with the email address created above
User = "rsconnect@rstudio.com"

; Replace this value with the App Password created above
Password = "app-password"

[Server]
; Replace this value with the email address created above
SenderEmail = "rsconnect@rstudio.com"

; EmailTo is required to prevent emails without a To: header from going to spam.
; Other recipients are specified with a BCC header
; Replace this value with the email address created above
EmailTo = "rsconnect@rstudio.com"

EmailFromUserAddresses = true
EmailProvider = SMTP

 

After restarting RStudio Connect, emailed reports will appear to be sent from the email address of the currently signed-in user.  Scheduled report emails will now appear to be sent from the email address of the content owner.

 

Screen_Shot_2021-06-17_at_12.50.27_PM.png

 

To bypass spam filtering for senders within your domain, add an exception through the Google administration console. If you would like more fine-grained control over which senders are allowed to bypass the spam filter, you may use an approved sender address list as described here. Emails sent to or from an address outside your domain may be marked as spam. Check your spam folder if you don't see the message in your inbox.

 

Screen_Shot_2021-06-17_at_3.28.48_PM.png

Comments