function reroute_email_extract_addresses in Reroute Email 2.x
Extract email addresses from a string which may include display names.
Items may be separated by any number and combination of: spaces, commas, semicolons, or newlines.
Parameters
string $string: A string to be split into an array.
Return value
array An array of unique addresses from a string.
1 call to reroute_email_extract_addresses()
- reroute_email_check in ./
reroute_email.module - Helper function to determine a need to reroute.
File
- ./
reroute_email.module, line 306 - Intercepts all outgoing emails to be rerouted to a configurable destination.
Code
function reroute_email_extract_addresses(string $string) : array {
preg_match_all('/[^\\s,;\\n<]+@[^\\s,;\\n>]+/', $string, $addresses, PREG_PATTERN_ORDER);
// Remove duplications.
return array_unique($addresses[0]);
}