function create_header() {
      $header = array();
      $header[] = sprintf("Date: %s\r\n", $this->rfc_date());

      // To be created automatically by mail()
      if($this->Mailer != "mail")
         $header[] = $this->addr_append("To", $this->to);

      $header[] = sprintf("From: %s <%s>\r\n", $this->FromName, trim($this->From));
      if(count($this->cc) > 0)
         $header[] = $this->addr_append("Cc", $this->cc);

      // sendmail and mail() extract Bcc from the header before sending
      if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
         $header[] = $this->addr_append("Bcc", $this->bcc);

      if(count($this->ReplyTo) > 0)
         $header[] = $this->addr_append("Reply-to", $this->ReplyTo);

      // mail() sets the subject itself
      if($this->Mailer != "mail")
         $header[] = sprintf("Subject: %s\r\n", trim($this->Subject));

      $header[] = sprintf("X-Priority: %d\r\n", $this->Priority);
      $header[] = sprintf("X-Mailer: phpmailer [version %s]\r\n", $this->Version);
      $header[] = sprintf("Return-Path: %s\r\n", trim($this->From));

      // Add custom headers
      for($index = 0; $index < count($this->CustomHeader); $index++)
         $header[] = sprintf("%s\r\n", $this->CustomHeader[$index]);

      if($this->UseMSMailHeaders)
         $header[] = $this->AddMSMailHeaders();

      $header[] = "MIME-Version: 1.0\r\n";

      // Add all attachments
      if(count($this->attachment) > 0 || !empty($this->AltBody))
      {
         // Set message boundary
         $this->boundary = "_b" . md5(uniqid(time()));
         // Set message subboundary for multipart/alternative
         $this->subboundary = "_sb" . md5(uniqid(time()));

         $header[] = "Content-Type: Multipart/Mixed;\r\n";
         $header[] = sprintf(" boundary=\"Boundary-=%s\"\r\n\r\n", $this->boundary);
      }
      else
      {
         $header[] = sprintf("Content-Transfer-Encoding: %s\r\n", $this->Encoding);
         $header[] = sprintf("Content-Type: %s; charset = \"%s\"\r\n\r\n",
                             $this->ContentType, $this->CharSet);
      }

      return(join("", $header));
   }