1<?php 2/** 3 * Defines AJAX calls used to manipulate e-mail addresses. 4 * 5 * Copyright 2010-2017 Horde LLC (http://www.horde.org/) 6 * 7 * See the enclosed file COPYING for license information (LGPL). If you 8 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 9 * 10 * @author Michael Slusarz <slusarz@horde.org> 11 * @category Horde 12 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 13 * @package Core 14 */ 15class Horde_Core_Ajax_Application_Handler_Email extends Horde_Core_Ajax_Application_Handler 16{ 17 /** 18 * Default domain. 19 * 20 * @var string 21 */ 22 public $defaultDomain = null; 23 24 /** 25 * Parses a valid email address out of a complete address string. 26 * 27 * Variables used: 28 * - email: (string) An email address. 29 * 30 * @return object Object with the following properties: 31 * - email: (string) The parsed email address. 32 * 33 * @throws Horde_Exception 34 * @throws Horde_Mail_Exception 35 */ 36 public function parseEmailAddress() 37 { 38 $ob = new Horde_Mail_Rfc822_Address($this->vars->email); 39 if (is_null($ob->mailbox)) { 40 throw new Horde_Exception(Horde_Core_Translation::t("No valid email address found")); 41 } 42 43 if (is_null($ob->host) && !is_null($this->defaultDomain)) { 44 $ob->host = $this->defaultDomain; 45 } 46 47 $ret = new stdClass; 48 $ret->email = $ob->bare_address; 49 50 return $ret; 51 } 52 53} 54