/**
  * Send a message
  *
  * @param   peer.mail.Message message the Message object to send
  * @return  bool success
  */
 public function send(Message $message)
 {
     // Sanity check: Do we have at least one recipient?
     $to = '';
     for ($i = 0, $s = sizeof($message->to); $i < $s; $i++) {
         if (!$message->to[$i] instanceof \peer\mail\InternetAddress) {
             continue;
         }
         // Ignore!
         $to .= $message->to[$i]->toString($message->getCharset()) . ', ';
     }
     if (empty($to)) {
         throw new TransportException('No recipients defined (recipients[0]: ' . \xp::typeOf($message->to[0]), new \lang\IllegalArgumentException('Recipient #0 is not an InternetAddress object'));
     }
     // Copy message and unset To / Subject. PHPs mail() function will add them
     // to the mail twice, otherwise
     $tmp = clone $message;
     unset($tmp->to);
     unset($tmp->subject);
     if (false === mail(substr($to, 0, -2), QuotedPrintable::encode($message->getSubject(), $message->getCharset()), strtr($message->getBody(), ["\r\n" => "\n", "\r" => "\n"]), rtrim($tmp->getHeaderString(), "\n"), $this->parameters)) {
         throw new TransportException('Could not send mail to ' . \xp::stringOf($message->to[0]), new \io\IOException('Call to mail() failed'));
     }
     return true;
 }