You are here

function simplenews_mask_mail in Simplenews 8

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_mask_mail()
  2. 6.2 includes/simplenews.subscription.inc \simplenews_mask_mail()
  3. 6 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.

6 calls to simplenews_mask_mail()
ConfirmAddForm::buildForm in src/Form/ConfirmAddForm.php
Form constructor.
ConfirmMultiForm::buildForm in src/Form/ConfirmMultiForm.php
Form constructor.
ConfirmRemovalForm::buildForm in src/Form/ConfirmRemovalForm.php
Form constructor.
SimplenewsKernelTest::testMasking in tests/src/Kernel/SimplenewsKernelTest.php
SimplenewsSubscribeTest::testSubscribeAnonymous in src/Tests/SimplenewsSubscribeTest.php
testSubscribeAnonymous

... See full list

File

./simplenews.module, line 1113
Simplenews node handling, sent email, newsletter block and general hooks

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);
  }
}