4 * AddressStructure.class.php
6 * This file contains functions needed to extract email address headers from
9 * @copyright © 2003-2007 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
18 * Class used to work with email address headers
19 * @package squirrelmail
23 class AddressStructure
{
25 * Personal information
30 * @todo check use of this variable. var is not used in class.
45 * @todo check use of this variable. var is not used in class.
51 * Return address information from mime headers.
52 * @param boolean $full return full address (true) or only personal if it exists, otherwise email (false)
53 * @param boolean $encoded (since 1.4.0) return rfc2047 encoded address (true) or plain text (false).
56 function getAddress($full = true, $encoded = false) {
58 if (is_object($this)) {
59 $email = ($this->host ?
$this->mailbox
.'@'.$this->host
61 $personal = trim($this->personal
);
63 if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) {
67 if ($encoded && !$is_encoded) {
68 $personal_encoded = encodeHeader($personal);
69 if ($personal !== $personal_encoded) {
70 $personal = $personal_encoded;
72 $personal = '"'.$this->personal
.'"';
76 $personal = '"'.$this->personal
.'"';
79 $addr = ($email ?
$personal . ' <' .$email.'>'
81 $best_dpl = $this->personal
;
86 $result = ($full ?
$addr : $best_dpl);
92 * Shorter version of getAddress() function
93 * Returns full encoded address.
97 function getEncodedAddress() {
98 return $this->getAddress(true, true);
102 * Return just the email portion of this address
106 function getEmail () {
108 if (is_object($this)) {
109 $r = $this->host ?
$this->mailbox
.'@'.$this->host
: $this->mailbox
;