Check if an email address contains a domain with a record of spamming

From pmusers
Jump to: navigation, search

Use trigger code to check whether the domain in an email address is found in's list of blacklisted domains. If found in the blacklist, then use PMFRedirectToStep() to redirect back to the Dynaform, and tell the user to enter a different email address.

Process: Check_email_for_spam_blacklist-1.pmx (right click and select Save link as)
Author: Amos Batto (
Version: 1.0 (2018-09-03)
Tested in: ProcessMaker 3.2.2 Enterprise in Debian 8.4 with Firefox 51

Create the following DynaForm, which has a text field associated with the "email" variable:


Then create the following trigger which checks if the domain of the entered email address is found in's blacklist:

//set to the ID of the dynaform containing the "email" field:
$dynaformId = '6862687465b64de53f32e86007678473'; 
//to test set @@email to "nobody@"

if (@@email) {
   $g = new G();
   if (preg_match('/@([a-zA-Z0-9\-_.]+)/', @@email, $aMatches) == 0) {
      $g->sendMessageText(@@email.' does not contain a valid domain. ". 
          "Enter another email address.', 'WARNING');
      PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
   $ip = $domain = $aMatches[1];
   //if the domain is not an IP address, then lookup the IP address for the domain
   if (preg_match('/^(\d{1,3}\.){3,5}\d{1,3}$/', $domain) == 0) {
      $ip = gethostbyname($domain);
      if ($ip == $domain) {
         $g->sendMessageText("Cannot find IP for domain '$domain'. ".
            "Enter another email address.", 'WARNING');
         PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
    $blacklist = '';
    $reversedIp = implode(".", array_reverse(explode(".", $ip)));
   //The following code doesn't work if needing to specify an alternative DNS:
   $aRecords = dns_get_record($reversedIp .'.'. $blacklist);
   if (!empty($aRecords)) { 
        $g->sendMessageText("The domain '$domain' has a record of sending spam. ".
                  "Enter another email address.", 'WARNING');
      PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
   //use the "dig" command instead of dns_get_record(), but only works in Linux:
    $dns = ''; //set to your DNS server
   $cmd = "dig +short $reversedIp.$blacklist @".$dns;
   @@feedback = exec($cmd); 
   if (@@feedback and trim(@@feedback) != '') {
      $g->sendMessageText("The domain '$domain' has a record of sending spam. ".
                  "Enter another email address.", 'WARNING');
      PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);

This trigger code will work if ProcessMaker is installed in a server running Linux. If using Windows or not needing to use an alternative DNS, then uncomment the code which uses the dns_get_record() function to lookup the domain in's blacklist.

This code will redirect the user back to the Dynaform and display a warning message to the user if an email address is entered which comes from an invalid domain or it is found in's blacklist: