ehloName = ($this->value !== '') ? $this->value : null; $cps = $this->getComments(); $commentPart = (!empty($cps)) ? $cps[0] : null; $pattern = '~^(\[(IPv[64])?(?P[a-f\d\.\:]+)\])?\s*(helo=)?(?P[a-z0-9\-]+[a-z0-9\-\.]+)?\s*(\[(IPv[64])?(?P[a-f\d\.\:]+)\])?$~i'; if ($commentPart !== null && \preg_match($pattern, $commentPart->getComment(), $matches)) { $this->value .= ' (' . $commentPart->getComment() . ')'; $this->hostname = (!empty($matches['name'])) ? $matches['name'] : null; $this->address = (!empty($matches['addr1'])) ? $matches['addr1'] : ((!empty($matches['addr2'])) ? $matches['addr2'] : null); } } /** * Returns the name used to identify the server in the first part of the * extended-domain line. * * Note that this is not necessarily the name used in the EHLO line to an * SMTP server, since implementations differ so much, not much can be * guaranteed except the position it was parsed in. */ public function getEhloName() : ?string { return $this->ehloName; } /** * Returns the hostname of the server, or whatever string in the hostname * position when parsing (but never an address). */ public function getHostname() : ?string { return $this->hostname; } /** * Returns the address of the server, or whatever string that looks like an * address in the address position when parsing (but never a hostname). */ public function getAddress() : ?string { return $this->address; } }