Configuring Mail server to use with a REDCap VM

This guide is helpful to configure a REDCap application running on a Linux host to use an external SMTP/mail server for handling email exchange.  This guide is using the myARCH REDCap VM as a guide, which is running CentOS 7 with the normal AMP stack on top of it.  We will use the onboard Postfix mail server as a null email client, relaying all requests from the php mail() function to the email server.  The following will be performed as 'root' from the command line of the REDCap server.

(Optional) Create a file that has the SMTP server credentials (if authentication is required)

  1. Create a file /etc/postfix/sasl_password and add the following line:
    <smtp-server>        <username>:<password>
    where
      – <smtp-server> is the hostname/domain of the server (e.g. smtp.sendgrid.net)
      – <username> is the login user to the server
      – <password> is the user's password
  2. Restrict permissions of the above file to root by typing the following:
    chown root:root /etc/postfix/sasl_passwd && chmod 600 /etc/postfix/sasl_passwd
  3. Create a DB file for the password file:
    postmap hash:/etc/postfix/sasl_passwd

Configure Postfix

  1. Open the file /etc/postfix/main.cf and add/edit the following lines to look like the following:
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options =
  2. Also in /etc/postfix/main.cf, edit the following:
    myhostname = <hostname-of-redcap-vm>
    
    #$mydomain (commented out - this will revert to the domain portion of myhostname if specified)
    myorigin = $mydomain
    inet_interfaces = loopback-only
    mydestination =
    relayhost = <SMTP-server>:<SMTP-port>


  3. Reload Postfix with the new configuration:
    postfix reload