You are here

function simplenews_mask_mail in Simplenews 6

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_mask_mail()
  2. 8 simplenews.module \simplenews_mask_mail()
  3. 6.2 includes/simplenews.subscription.inc \simplenews_mask_mail()
  4. 7.2 includes/simplenews.subscription.inc \simplenews_mask_mail()
  5. 7 includes/simplenews.subscription.inc \simplenews_mask_mail()
  6. 3.x simplenews.module \simplenews_mask_mail()

Mask a mail address.

For example, name@example.org will be masked as n*****@e*****.org.

Parameters

$mail: A valid mail address to mask.

Return value

The masked mail address.

2 calls to simplenews_mask_mail()
simplenews_confirm_add_form in ./simplenews.subscription.inc
Generate the confirm subscription form.
simplenews_confirm_removal_form in ./simplenews.subscription.inc
Generate the confirm unsubscription form.

File

./simplenews.subscription.inc, line 138
(Un)subscription and (un)subscription confirmation

Code

function simplenews_mask_mail($mail) {
  if (preg_match('/^(.).*@(.).*(\\..+)$/', $mail)) {
    return preg_replace('/^(.).*@(.).*(\\..+)$/', '$1*****@$2*****$3', $mail);
  }
  else {

    // Missing top-level domain.
    return preg_replace('/^(.).*@(.).*$/', '$1*****@$2*****', $mail);
  }
}