You are here

function salesforce_api_valid_email_address in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7.2 salesforce_api/salesforce_api.module \salesforce_api_valid_email_address()

Salesforce does not accept email addresses with relative domains, like root@localhost. This function is based on Drupal's valid_email_address. Greater men than I have tried and failed to capture valid email addresses with simple regular expressions. This function merely tries to mimic Salesforce's validation rules, NOT to capture all valid email addresses.

1 call to salesforce_api_valid_email_address()
salesforce_api_fieldmap_export_create in salesforce_api/salesforce_api.module
Creates an object for export to Salesforce based on the supplied Drupal object and fieldmap.


salesforce_api/salesforce_api.module, line 579
Defines an API that enables modules to interact with the Salesforce server.


function salesforce_api_valid_email_address($mail) {
  $user = '[a-zA-Z0-9_\\-\\.\\+\\^!#\\$%&*+\\/\\=\\?\\`\\|\\{\\}~\']+';
  $domain = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])';
  $tld = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])+';
  $domain = '(?:' . $domain . '\\.)+' . $tld;
  $ipv4 = '[0-9]{1,3}(\\.[0-9]{1,3}){3}';
  return preg_match("/^{$user}@({$domain}|(\\[({$ipv4})\\]))\$/", $mail);