CloudObjects / Directory / Lukas Rosenstock / EMailHelperFunctions
Sign in

EMailHelperFunctions

a phpmae:Class in Lukas Rosenstock
Public PHP Methods
  • getDisplayName($rfc_email_string)

    Get a display name from an RFC string.

    @param string $rfc_email_string
    @return string

  • getEMail($rfc_email_string)

    Helper function to get an email from an RFC string.
    taken from: http://php.net/manual/en/function.mailparse-rfc822-parse-addresses.php
    @param string $rfc_email_string
    @return string

Source Code
<?php

/**
 * Implementation for coid://lukasrosenstock.net/EMailHelperFunctions
 */
class EMailHelperFunctions {

    /**
     * Get a display name from an RFC string.
     * 
     * @param string $rfc_email_string
     * @return string
     */
    public function getDisplayName($rfc_email_string) {
        // taken from: http://php.net/manual/en/function.mailparse-rfc822-parse-addresses.php
        preg_match('/[\w\s]+/', $rfc_email_string, $matches);
        return (count($matches) > 0) ? trim($matches[0]) : "";
    }

    /**
     * Helper function to get an email from an RFC string.
     * taken from: http://php.net/manual/en/function.mailparse-rfc822-parse-addresses.php
     * @param string $rfc_email_string
     * @return string
     */
    public function getEMail($rfc_email_string) {
        // taken from: http://php.net/manual/en/function.mailparse-rfc822-parse-addresses.php
        preg_match('/(?:<)(.+)(?:>)$/', $rfc_email_string, $matches);
        return (count($matches) > 1) ? trim($matches[1]) : trim($rfc_email_string);
    }

}
Meta
URI / COID
coid://lukasrosenstock.net/EMailHelperFunctions content_copy
Revision
5-8f4883669824866669fa016942a37f03 content_copy
Last updated
2019-11-13 14:27 (UTC)
Usage permission
co:Public
Objects in this namespace