src/Mail/MailService.php
public function send($mail, array $options = array())
    {
        if (!$mail instanceof MailMessage) {
            $mail = $this->get($mail, $options);
        }

        $headers   = $mail->getHeaders();
        $transport = $this->getTransport();

        if (!$mail->isValid() && $this->from) {
            $mail->setFrom($this->from);
        }

        if ($this->overrideRecipient instanceof AddressList) {
            $originalRecipient = $headers->get('to')->toString();
            if ($headers->has('cc')) {
                $originalRecipient .= '; ' . $headers->get('cc')->toString();
                $headers->removeHeader('cc');
            }
            if ($headers->has('bcc')) {
                $originalRecipient .= '; ' . $headers->get('bcc')->toString();
                $headers->removeHeader('bcc');
            }
            $headers->addHeaderLine('X-Original-Recipients', $originalRecipient);
            $mail->setTo($this->overrideRecipient);
        }

        if (!$headers->has('X-Mailer')) {
            $mailerHeader = new \Zend\Mail\Header\GenericHeader('X-Mailer', $this->getMailer());
            $headers->addHeader($mailerHeader);
            $mailerHeader->setEncoding('ASCII'); // get rid of other encodings for this header!
        }

        /* Allow HTMLTemplateMails to alter subject in the view script.
         * As the Zend Transport class build subject before the getBodyText call,
         * we have to call it here.
         */
        if ($mail instanceof \Core\Mail\HTMLTemplateMessage) {
            $mail->getBodyText();
        }

        $transport->send($mail);
    }
public function send($mail, array $options = array())
    {
        if (!$mail instanceof MailMessage) {
            $mail = $this->get($mail, $options);
        }

        $headers   = $mail->getHeaders();
        $transport = $this->getTransport();

        if (!$mail->isValid() && $this->from) {
            $mail->setFrom($this->from);
        }

        if ($this->overrideRecipient instanceof AddressList) {
            $originalRecipient = $headers->get('to')->toString();
            if ($headers->has('cc')) {
                $originalRecipient .= '; ' . $headers->get('cc')->toString();
                $headers->removeHeader('cc');
            }
            if ($headers->has('bcc')) {
                $originalRecipient .= '; ' . $headers->get('bcc')->toString();
                $headers->removeHeader('bcc');
            }
            $headers->addHeaderLine('X-Original-Recipients', $originalRecipient);
            $mail->setTo($this->overrideRecipient);
        }

        if (!$headers->has('X-Mailer')) {
            $mailerHeader = new \Zend\Mail\Header\GenericHeader('X-Mailer', $this->getMailer());
            $headers->addHeader($mailerHeader);
            $mailerHeader->setEncoding('ASCII'); // get rid of other encodings for this header!
        }

        /* Allow HTMLTemplateMails to alter subject in the view script.
         * As the Zend Transport class build subject before the getBodyText call,
         * we have to call it here.
         */
        if ($mail instanceof \Core\Mail\HTMLTemplateMessage) {
            $mail->getBodyText();
        }

        $transport->send($mail);
    }
Sends a mail.

Sets default values where needed.

@param string|MailMessage $mail
@param array          $options