/** * Prepare additional_parameters argument * * Basically, overrides the MAIL FROM envelope with either the Sender or * From address. * * @param \Zend\Mail\Message $message * @return string */ protected function prepareParameters(Mail\Message $message) { if ($this->isWindowsOs()) { return null; } $parameters = (string) $this->parameters; $sender = $message->getSender(); if ($sender instanceof AddressInterface) { $parameters .= ' -f ' . $sender->getEmail(); return $parameters; } $from = $message->getFrom(); if (count($from)) { $from->rewind(); $sender = $from->current(); $parameters .= ' -f ' . $sender->getEmail(); return $parameters; } return $parameters; }
/** * Retrieve email address for envelope FROM * * @param Message $message * @throws Exception\RuntimeException * @return string */ protected function prepareFromAddress(Message $message) { $sender = $message->getSender(); if ($sender instanceof Address\AddressInterface) { return $sender->getEmail(); } $from = $message->getFrom(); if (!count($from)) { // Per RFC 2822 3.6 throw new Exception\RuntimeException(sprintf('%s transport expects either a Sender or at least one From address in the Message; none provided', __CLASS__)); } $from->rewind(); $sender = $from->current(); return $sender->getEmail(); }