/** * Creates header. */ private function createHeader() { $this->addHeaderLine('Date', $this->result->datetime->email); $this->addHeaderLine('Return-Path', '<' . $this->clearHeaderValue($this->email->from->email) . '>'); $this->addHeaderLine('From', $this->formatAddress($this->email->from)); $this->addHeaderLine('Subject', $this->encodeHeader($this->changeCharset($this->clearHeaderValue($this->email->subject)))); if (!empty($this->email->to)) { $this->addHeaderLine('To', $this->formatAddressList($this->email->to)); } elseif (empty($this->email->cc)) { // Only blind carbon copy recipients $this->addHeaderLine('To', 'undisclosed-recipients:;'); } if (!empty($this->email->cc)) { $this->addHeaderLine('Cc', $this->formatAddressList($this->email->cc)); } if (!empty($this->email->bcc)) { $this->addHeaderLine('Bcc', $this->formatAddressList($this->email->bcc)); } if (!empty($this->email->replyTo)) { $this->addHeaderLine('Reply-To', $this->formatAddressList($this->email->replyTo)); } if (!empty($this->email->confirmReadingTo)) { $this->addHeaderLine('Disposition-Notification-To', $this->formatAddress($this->email->confirmReadingTo)); } if (!empty($this->email->priority)) { $this->addHeaderLine('X-Priority', (string) $this->email->priority); } $this->addHeaderLine('Message-ID', '<' . $this->result->messageId . '>'); if (!empty($this->email->inReplyTo)) { $this->addHeaderLine('In-Reply-To', '<' . $this->clearHeaderValue($this->email->inReplyTo) . '>'); } if (!empty($this->email->references)) { $references = $this->email->references; foreach ($references as $key => $reference) { $references[$key] = $this->clearHeaderValue($reference); } $this->addHeaderLine('References', '<' . implode('> <', $references) . '>'); } if (!empty($this->xmailer)) { $this->addHeaderLine('X-Mailer', $this->changeCharset($this->clearHeaderValue($this->xmailer))); } $this->addHeaderLine('MIME-Version', '1.0'); // Custom headers foreach ($this->email->headers as $header) { $this->addHeaderLine($this->changeCharset($this->clearHeaderValue($header->name)), $this->encodeHeader($this->clearHeaderValue($header->value))); } switch ($this->type) { case self::TYPE_ATTACHMENTS: // Break missing intentionally // Break missing intentionally case self::TYPE_ALTERNATIVE_ATTACHMENTS: $subtype = $this->email->hasInlineAttachments() ? 'related' : 'mixed'; $this->addHeaderLine('Content-Type', 'multipart/' . $subtype . ';' . self::LINE_END . ' boundary="' . $this->boundary[1] . '"'); break; case self::TYPE_ALTERNATIVE: $this->addHeaderLine('Content-Type', 'multipart/alternative;' . self::LINE_END . ' boundary="' . $this->boundary[1] . '"'); break; case self::TYPE_SIMPLE: // Break missing intentionally // Break missing intentionally default: $contentType = $this->email->body->isHtml() ? 'text/html' : 'text/plain'; $this->addHeaderLine('Content-Type', $contentType . '; charset="' . $this->clearHeaderValue($this->charset) . '"'); $this->addHeaderLine('Content-Transfer-Encoding', $this->encoding); break; } }