Contao\Idna::decodeEmail PHP Method

decodeEmail() public static method

Decode the domain in an e-mail address
public static decodeEmail ( string $strEmail ) : string
$strEmail string The e-mail address
return string The decoded e-mail address
    public static function decodeEmail($strEmail)
    {
        if ($strEmail == '') {
            return '';
        }
        if (strpos($strEmail, '@') === false) {
            return $strEmail;
            // see #6241
        }
        $arrChunks = explode('@', $strEmail);
        $strHost = array_pop($arrChunks);
        return implode('@', $arrChunks) . '@' . static::decode($strHost);
    }

Usage Example

 /**
  * Create a new user and redirect
  *
  * @param MemberModel $objMember
  */
 protected function sendPasswordLink($objMember)
 {
     $confirmationId = md5(uniqid(mt_rand(), true));
     // Store the confirmation ID
     $objMember = \MemberModel::findByPk($objMember->id);
     $objMember->activation = $confirmationId;
     $objMember->save();
     // Prepare the simple token data
     $arrData = $objMember->row();
     $arrData['domain'] = \Idna::decode(\Environment::get('host'));
     $arrData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
     // Send e-mail
     $objEmail = new \Email();
     $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['passwordSubject'], \Idna::decode(\Environment::get('host')));
     $objEmail->text = \StringUtil::parseSimpleTokens($this->reg_password, $arrData);
     $objEmail->sendTo($objMember->email);
     $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . \Idna::decodeEmail($objMember->email) . ')', __METHOD__, TL_ACCESS);
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     $this->reload();
 }
All Usage Examples Of Contao\Idna::decodeEmail