PHP code example of nepada / email-address

1. Go to this page and download the library: Download nepada/email-address library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nepada / email-address example snippets


$rfcEmailAddress = Nepada\EmailAddress\RfcEmailAddress::fromString('Real.example+suffix@HÁČKYčárky.cz');
$rfcEmailAddress = Nepada\EmailAddress\RfcEmailAddress::fromDomainAndLocalPart('HÁČKYčárky.cz', 'Real.example+suffix');

$ciEmailAddress = Nepada\EmailAddress\CaseInsensitiveEmailAddress::fromString('Real.example+suffix@HÁČKYčárky.cz');
$ciEmailAddress = Nepada\EmailAddress\CaseInsensitiveEmailAddress::fromDomainAndLocalPart('HÁČKYčárky.cz', 'Real.example+suffix');

echo((string) $emailAddress); // Real.example+suffix@HÁČKYčárky.cz
echo($emailAddress->toString()); // Real.example+suffix@HÁČKYčárky.cz

echo($emailAddress->getValue()); // [email protected]

echo($emailAddress->getLocalPart()); // real.example+suffix
echo($emailAddress->getDomain()); // xn--hkyrky-ptac70bc.cz