Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MailboxHeader.php

class MailboxHeader

A Mailbox MIME Header for something like Sender (one named address).

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Component\Mime\Header\AbstractHeader implements \Symfony\Component\Mime\Header\HeaderInterface
    • class \Symfony\Component\Mime\Header\MailboxHeader extends \Symfony\Component\Mime\Header\AbstractHeader

Expanded class hierarchy of MailboxHeader

2 files declare their use of MailboxHeader
EmailAddressContains.php in vendor/symfony/mime/Test/Constraint/EmailAddressContains.php
MailManager.php in core/lib/Drupal/Core/Mail/MailManager.php

File

vendor/symfony/mime/Header/MailboxHeader.php, line 22

Namespace

Symfony\Component\Mime\Header
View source
final class MailboxHeader extends AbstractHeader {
    private Address $address;
    public function __construct(string $name, Address $address) {
        parent::__construct($name);
        $this->setAddress($address);
    }
    
    /**
     * @param Address $body
     *
     * @throws RfcComplianceException
     */
    public function setBody(mixed $body) : void {
        $this->setAddress($body);
    }
    
    /**
     * @throws RfcComplianceException
     */
    public function getBody() : Address {
        return $this->getAddress();
    }
    
    /**
     * @throws RfcComplianceException
     */
    public function setAddress(Address $address) : void {
        $this->address = $address;
    }
    public function getAddress() : Address {
        return $this->address;
    }
    public function getBodyAsString() : string {
        $str = $this->address
            ->getEncodedAddress();
        if ($name = $this->address
            ->getName()) {
            $str = $this->createPhrase($this, $name, $this->getCharset(), true) . ' <' . $str . '>';
        }
        return $str;
    }
    
    /**
     * Redefine the encoding requirements for an address.
     *
     * All "specials" must be encoded as the full header value will not be quoted
     *
     * @see RFC 2822 3.2.1
     */
    protected function tokenNeedsEncoding(string $token) : bool {
        return preg_match('/[()<>\\[\\]:;@\\,."]/', $token) || parent::tokenNeedsEncoding($token);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AbstractHeader::$charset private property
AbstractHeader::$encoder private static property 1
AbstractHeader::$lang private property
AbstractHeader::$lineLength private property
AbstractHeader::$name private property
AbstractHeader::createPhrase protected function Produces a compliant, formatted RFC 2822 &#039;phrase&#039; based on the string given.
AbstractHeader::encodeWords protected function Encode needed word tokens within a string of input.
AbstractHeader::generateTokenLines protected function Generates tokens from the given string which include CRLF as individual tokens.
AbstractHeader::getCharset public function Overrides HeaderInterface::getCharset
AbstractHeader::getEncodableWordTokens protected function Splits a string into tokens in blocks of words which can be encoded quickly.
AbstractHeader::getLanguage public function Overrides HeaderInterface::getLanguage
AbstractHeader::getMaxLineLength public function Overrides HeaderInterface::getMaxLineLength
AbstractHeader::getName public function Overrides HeaderInterface::getName
AbstractHeader::getTokenAsEncodedWord protected function Get a token as an encoded word for safe insertion into headers.
AbstractHeader::PHRASE_PATTERN public constant
AbstractHeader::setCharset public function Overrides HeaderInterface::setCharset
AbstractHeader::setLanguage public function Set the language used in this Header. Overrides HeaderInterface::setLanguage
AbstractHeader::setMaxLineLength public function Overrides HeaderInterface::setMaxLineLength
AbstractHeader::tokensToString private function Takes an array of tokens which appear in the header and turns them into
an RFC 2822 compliant string, adding FWSP where needed.
AbstractHeader::toString public function Gets this Header rendered as a compliant string. Overrides HeaderInterface::toString
AbstractHeader::toTokens protected function Generate a list of all tokens in the final header. 1
MailboxHeader::$address private property
MailboxHeader::getAddress public function
MailboxHeader::getBody public function Overrides HeaderInterface::getBody
MailboxHeader::getBodyAsString public function Gets the header&#039;s body, prepared for folding into a final header value. Overrides HeaderInterface::getBodyAsString
MailboxHeader::setAddress public function
MailboxHeader::setBody public function Overrides HeaderInterface::setBody
MailboxHeader::tokenNeedsEncoding protected function Redefine the encoding requirements for an address. Overrides AbstractHeader::tokenNeedsEncoding
MailboxHeader::__construct public function Overrides AbstractHeader::__construct

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal