You are here

function simplenews_mask_mail in Simplenews 7

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. 6 simplenews.subscription.inc \simplenews_mask_mail()
  5. 7.2 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.

6 calls to simplenews_mask_mail()
SimplenewsSubscribeTestCase::testSubscribeAnonymous in tests/simplenews.test
testSubscribeAnonymous
SimplenewsSubscribeTestCase::testSubscribeMultiple in tests/simplenews.test
Subscribe to multiple newsletters at the same time.
SimplenewsUnitTest::testMasking in tests/simplenews.test
simplenews_confirm_add_form in includes/simplenews.subscription.inc
Generate the confirm subscription form.
simplenews_confirm_multi_form in includes/simplenews.subscription.inc
Generate the confirm subscription form.

... See full list

File

includes/simplenews.subscription.inc, line 666
(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);
  }
}