4 * AddressStructure.class.php
6 * This file contains functions needed to extract email address headers from
9 * @copyright 2003-2017 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).
54 * @param boolean $unconditionally_quote (since 1.4.21/1.5.2) when TRUE, always quote the personal part, whether or not it is encoded, otherwise quoting is only added if the personal part is not encoded
58 function getAddress($full = true, $encoded = false, $unconditionally_quote = FALSE) {
60 if (is_object($this)) {
61 $email = ($this->host ?
$this->mailbox
.'@'.$this->host
63 $personal = trim($this->personal
);
65 if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/i',$personal,$reg)) {
69 if ($encoded && !$is_encoded) {
70 $personal_encoded = encodeHeader('"' . $personal . '"');
71 if ($personal !== $personal_encoded) {
72 $personal = $personal_encoded;
74 //FIXME: this probably adds quotes around an encoded string which itself is already quoted
75 $personal = '"' . $this->personal
. '"';
78 if (!$is_encoded ||
$unconditionally_quote) {
79 $personal = '"' . $this->personal
. '"';
82 $addr = ($email ?
$personal . ' <' .$email.'>'
84 $best_dpl = $this->personal
;
89 $result = ($full ?
$addr : $best_dpl);
95 * Shorter version of getAddress() function
96 * Returns full encoded address.
97 * @param boolean $unconditionally_quote (since 1.4.21/1.5.2) when TRUE, always quote the personal part, whether or not it is encoded, otherwise quoting is only added if the personal part is not encoded
102 function getEncodedAddress($unconditionally_quote=FALSE) {
103 return $this->getAddress(true, true, $unconditionally_quote);
107 * Return just the email portion of this address
111 function getEmail () {
113 if (is_object($this)) {
114 $r = $this->host ?
$this->mailbox
.'@'.$this->host
: $this->mailbox
;