5 use Zend\Mail\Address as ZendAddress;
7 use Zend\Validator\EmailAddress as EmailAddressValidator;
32 if (preg_match(
"/[\r\n]/",
$email)) {
36 $emailAddressValidator =
new EmailAddressValidator(Hostname::ALLOW_DNS | Hostname::ALLOW_LOCAL);
37 if (!$emailAddressValidator->isValid(
$email)) {
38 $invalidMessages = $emailAddressValidator->getMessages();
56 if (!is_string(
$name)) {
60 if (preg_match(
"/[\r\n]/",
$name)) {
89 public static function fromString($contact, $ignored = null) {
90 $containsName = preg_match(
'/<(.*)>/', $contact, $matches) == 1;
92 $name = trim(substr($contact, 0, strpos($contact,
'<')));
93 return new self($matches[1],
$name);
95 return new self(trim($contact));
113 return $mail->toString();
if(!$user||!$user->canDelete()) $name
static fromString($contact, $ignored=null)
Parses strings like "Evan <evan@elgg.org>" into name/email objects.
static getFormattedEmailAddress($email, $name=null)
Format an email address and name into a formatted email address.
setName($name)
Set the name.
unsetName()
Clear the name from the email address.
setEmail($email)
Set the email address.