Contao\Idna::encodeEmail PHP Method

encodeEmail() public static method

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

Usage Example

 /**
  * Remove the recipient
  */
 protected function removeSubscriber()
 {
     $varInput = Idna::encodeEmail(Input::get('email', true));
     // Validate e-mail address
     if (!Validator::isEmail($varInput)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['email'];
         $this->redirect($this->generateFrontendUrl($this->objModel->getRelated('jumpTo')->row()));
     }
     $objCleverReach = new CleverReach();
     switch ($this->clr_unsubscribe) {
         case 'inactive':
             foreach ($this->clr_groups as $strGroupId) {
                 $objCleverReach->receiverSetInactive($varInput, $strGroupId);
             }
             break;
         case 'delete':
             foreach ($this->clr_groups as $strGroupId) {
                 $objCleverReach->receiverDelete($varInput, $strGroupId);
             }
             break;
         case 'email':
         default:
             $objCleverReach->sendUnsubscribeMail($varInput, $this->clr_form);
             break;
     }
     $this->redirect($this->generateFrontendUrl($this->objModel->getRelated('jumpTo')->row()));
 }
All Usage Examples Of Contao\Idna::encodeEmail