Handles the case of a quoted name

@param array $emailAddress
337987
private function handleQuote(array &$emailAddress)
    {
        if ($emailAddress['quote_temp']) {
            $emailAddress['name_parsed'] .= $emailAddress['quote_temp'];
            $emailAddress['name_quoted'] = true;
            $emailAddress['quote_temp'] = '';
        } elseif ($emailAddress['address_temp']) {
            $emailAddress['name_parsed'] .= $emailAddress['address_temp'];
            $emailAddress['name_quoted'] = $emailAddress['address_temp_quoted'];
            $emailAddress['address_temp_quoted'] = false;
            $emailAddress['address_temp'] = '';
            if ($emailAddress['address_temp_period'] > 0) {
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = 'Periods within the name of an email address must appear in quotes, such as "John Q. Public" <john@qpublic.com>';
            }
        }
    }
985363
protected function emailToArray($var)
    {
        if ($var === null) {
            return null;
        }
        if (!is_string($var) && !is_array($var)) {
            throw new InvalidArgumentException(
                sprintf('Email address must be an array or a string. (%s given)', gettype($var))
            );
        }

        // Assuming nobody's gonna set an email that is just a display name
        if (is_string($var)) {
            $regexp = '/([\w\s\'\"-_]+[\s]+)?(<)?(([\w-\._\+]+)@((?:[\w-_]+\.)+)([a-zA-Z]{2,4}))?(>)?/u';
            preg_match($regexp, $var, $out);
            $arr = [
                'email' => (isset($out[3]) ? trim($out[3]) : ''),
                'name'  => (isset($out[1]) ? trim(trim($out[1]), '\'"') : '')
            ];
        } else {
            $arr = $var;
        }

        if (!isset($arr['name'])) {
            $arr['name'] = '';
        }

        return $arr;
    }
667466
def quote_address(address: str) -> str:
    
    display_name, parsed_address = email.utils.parseaddr(address)
    if parsed_address:
        quoted_address = "<{}>".format(parsed_address)
    # parseaddr couldn't parse it, use it as is and hope for the best.
    else:
        quoted_address = "<{}>".format(address.strip())

    return quoted_address
169641
public function replyTo($emailAddress)
    {
        try {
            $this->mailer->AddReplyTo($emailAddress);
        } catch (phpmailerException $e) {
            throw new EmailException($e->getMessage(), $e->getCode());
        }

        return $this;
    }
473613
protected function getAddressValue(string $email, string $name = null)
    {
        if ($name === null || $name == '') {
            return $email;
        } else {
            return "{$name} <{$email}>";
        }
    }
1025166
public function addAddress($email, $name = '')
    {
        if (empty($email)) {
            throw new MailerException('email is required for addAddress!');
        }

        $this->_mailer->addAddress($email, $name);

        return $this;
    }
285293
public function setSenderEmailAddress($email)
    {
        if (!$this->validateHeaderFieldValue($email)) {
            throw new EmailValidationException(__('Sender Email Address can not contain carriage return or newlines.'));
        }

        $this->_sender_email_address = $email;
    }
200220
public function updateAttributeValueFromTextRepresentation($textRepresentation, ErrorList $warnings)
    {
        $good = true;
        if ($textRepresentation !== '') {
            if (!$this->app->make(EmailValidator::class)->isValid($textRepresentation)) {
                $good = false;
                $warnings->add(t('"%1$s" is not a valid email address for the attribute with handle %2$s', $textRepresentation, $this->attributeKey->getAttributeKeyHandle()));
            }
        }
        if ($good) {
            $value = parent::updateAttributeValueFromTextRepresentation($textRepresentation, $warnings);
        } else {
            $value = $this->getAttributeValueObject();
        }

        return $value;
    }
156160
protected function quoteNameString($name, $asSinglePart = false)
	{
		$q = $this->nameQuote . $this->nameQuote;

		// Double quote reserved keyword
		$name = str_replace($q[1], $q[1] . $q[1], $name);

		if ($asSinglePart)
		{
			return $q[0] . $name . $q[1];
		}

		return $q[0] . str_replace('.', "$q[1].$q[0]", $name) . $q[1];
	}
633255
function addCc( $email, $name = false )
    {
        $this->Mail->addCc( new ezcMailAddress( $email, $name, $this->usedCharset() ) );
        $this->CcElements[] = array( 'name' => $name,
                                     'email' => $email );
    }
1263999
public static function validateEmail($address, $tempEmailAllowed = true)
    {
        strpos($address, '@') ? list(, $mailDomain) = explode('@', $address) : $mailDomain = null;
        if (filter_var($address, FILTER_VALIDATE_EMAIL) &&
            !is_null($mailDomain) &&
            checkdnsrr($mailDomain, 'MX')
        ) {
            if ($tempEmailAllowed) {
                return true;
            } else {
                $handle = fopen(__DIR__.'/banned.txt', 'r');
                $temp = [];
                while (($line = fgets($handle)) !== false) {
                    $temp[] = trim($line);
                }
                if (in_array($mailDomain, $temp)) {
                    return false;
                }

                return true;
            }
        }

        return false;
    }
1092627
public function setName($name)
    {
        if (!is_string($name)) {
            throw new TypeException('$name must be of type string.');
        }

        /*
            Issue #368
            ==========
            If the name is not wrapped in double quotes and contains a comma or
            semicolon, the API fails to parse it correctly.
            When wrapped in double quotes, commas, semicolons and unescaped single
            quotes are supported.
            Escaped double quotes are supported as well but will appear unescaped in
            the mail (e.g. "O\'Keefe").
            Double quotes will be shown in some email clients, so the name should
            only be wrapped when necessary.
        */
        // Only wrapp in double quote if comma or semicolon are found
        if (false !== strpos($name, ',') || false !== strpos($name, ';')) {
            // Unescape quotes
            $name = stripslashes(html_entity_decode($name, ENT_QUOTES));
            // Escape only double quotes
            $name = str_replace('"', '\\"', $name);
            // Wrapp in double quotes
            $name = '"' . $name . '"';
        }
        $this->name = (!empty($name)) ? $name : null;
    }
877627
protected function isCorrectEmailAddress($email,$title='') {
		if (is_array($email)) {
			$email = $email['address'];
		}
		
		if ($title == '') {
			$title = 'Email';
		}
		
		if (trim($email) == '') {
			throw new \Exception($title.' address can not be empty');
		}
		
		// email can be in breakets
		if (preg_match('!<.+>!',$email,$f)) {
			$email = $f[1];
		}
		
		// check against regular expression
		$regexp = '!^[_a-z0-9-+]+(\\.[_a-z0-9-+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$!i';
		
		if (strpos($email,',') > 0) {
			// can be list of meails
			$emails = explode(',',$email);
			
			foreach ($emails as $email) {
				if (trim($email) == '') {
					return false;
				}
				if (!preg_match($regexp, $email)) {
					throw new \Exception($title.' address has wrong format');
				}
			}
			return true;
		}
		
		if (!preg_match($regexp, $email)) {
			throw new \Exception($title.' address has wrong format');
		}
		return true;
	}
638123
function setSender( $email, $name = false )
    {
        $this->Mail->from = new ezcMailAddress( $email, $name, $this->usedCharset() );
        $this->From = array( 'name' => $name,
                             'email' => $email );
    }
543623
def quote_as2name(unquoted_name):
    

    if re.search(r'[\\" ]', unquoted_name, re.M):
        return '"' + email.utils.quote(unquoted_name) + '"'
    else:
        return unquoted_name
618527
protected function addEmail($field, $email, $name = null)
    {
        if (is_array($email)) {
            foreach ($email as $mail => $name) {
                if (is_numeric($mail)) {
                    $mail = $name;
                    $name = null;
                }

                if ($mail === null) {
                    continue;
                }

                $this->$field($mail, $name);
            }

            return;
        }

        $email = Punycode::toAscii($email);

        $this->{$field}[$email] = $name;
    }
277899
public function getByEmail($emailAddress)
    {
        $path = new ResourcePathServiceOperation($this->getContext(),$this->getResourcePath(),"getByEmail",array($emailAddress));
        return new User($this->getContext(),$path);
    }