How to enable VERP for incoming mail delivery on Cpanel/WHM

Running software which handles bulk mailing such as the CiviCRM CiviMail component requires bounce processing if you don’t want your server to become blacklisted.  The preferred way to do this is using VERP handling (see https://en.wikipedia.org/wiki/Variable_envelope_return_path)

In CiviMail setup a bounce processing mailbox with username “bounce” and localpart “bounce+”.  Note you could use any username that you have created a mailbox for but the localpart must match it or the bounced email will not be sent to that user.

You need access to the root account on the VPS to do this.

  1. Login to WHM as root and browse to Exim Configuration Manager->Advanced Configuration
  2. Find the section “PREVIRTUALUSER” and enter the following (make sure you replace VERPDOMAIN with the actual domain that you want to use with VERP):
civicrm_user:
 driver = accept
 local_part_suffix = +*
 local_part_suffix_optional
 headers_remove="x-spam-exim"
 domains = VERPDOMAIN
 require_files = "+${extract{5}{::}{${lookup passwd{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}{$value}}}}/etc/$domain/passwd"
 condition = ${if eq {${lookup {$local_part} lsearch {${extract{5}{:}{${lookup passwd{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}{$value}}}}/etc/$domain/passwd}}}{} {false}{true}}
 transport = virtual_userdelivery

Change virtual_userdelivery to virtual_boxtrapper_userdelivery on newer versions of WHM/Cpanel

Testing

Use this command to check syntax:

exim -bV

The following command should show router = virtual_user if configured correctly.  If not correctly configured you will most likely see “No Such User Here”.

exim -bt bounce+1234@VERPDOMAIN

 

Leave a Reply

Your e-mail address will not be published. Required fields are marked *