/**
  * Message builder
  *
  * @return self
  */
 public function buildMessage()
 {
     $this->_buildInit();
     // From header
     if (is_array($this->from) && count($this->from) > 0) {
         $from = null;
         while (is_null($from) == true) {
             foreach ($this->from as $n => $m) {
                 $from = array($n => $m);
             }
         }
         $this->from = $from;
     }
     if (count($this->from) == 0) {
         $this->getMailer()->addError('No sender setted!');
     } else {
         $this->message .= Helper::listAddresses($this->from, 'from');
     }
     // To header
     if (count($this->to) > 0) {
         $this->message .= Helper::listAddresses($this->to, 'to');
     }
     // CC header
     if (count($this->cc) > 0) {
         $this->message .= Helper::listAddresses($this->cc, 'cc');
     }
     // BCC header
     if (count($this->bcc) > 0) {
         $this->message .= Helper::listAddresses($this->bcc, 'bcc');
     }
     // Headers
     foreach ($this->getMailer()->getRegistry('headers') as $entry => $v_entry) {
         if (isset($v_entry)) {
             $this->message .= Helper::headerTagger($entry, $v_entry) . Mailer::$LINE_ENDING;
         }
     }
     $bound = 0;
     // Mail type
     $type = $this->getMailer()->getRegistry('message_type');
     if (!is_null($type) && $type != 'text/plain') {
         $bound = 1;
         $this->message .= Helper::headerTagger("Content-Type", $type, array('boundary' => $this->getMailer()->getRegistry('boundary'))) . Mailer::$LINE_ENDING;
         $this->message .= "This is a multi-part message in MIME format." . Mailer::$LINE_ENDING;
         if ($type == 'multipart/mixed') {
             $this->message .= Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary') . Mailer::$LINE_ENDING;
             $this->message .= Helper::headerTagger("Content-Type", "multipart/alternative", array('boundary' => $this->getMailer()->getRegistry('boundary_ctt'))) . Mailer::$LINE_ENDING;
         }
     }
     // Text content
     if (strlen($this->text)) {
         if ($bound) {
             $this->message .= Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary_ctt') . Mailer::$LINE_ENDING;
             //ne prend pas les css en compte
             //                $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
             $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit") . Mailer::$LINE_ENDING;
             $this->message .= Helper::headerTagger("Content-Type", "text/plain", array('charset' => $this->getMailer()->getOption('charset'))) . Mailer::$LINE_ENDING;
         }
         $this->message .= Mailer::$LINE_ENDING . $this->text;
     }
     // HTML content
     if (strlen($this->html)) {
         if ($bound) {
             $this->message .= Mailer::$LINE_ENDING . Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary_ctt') . Mailer::$LINE_ENDING;
         }
         // prend les css en compte
         //            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
         $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit") . Mailer::$LINE_ENDING;
         //            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "quoted-printable").Mailer::$LINE_ENDING;
         $this->message .= Helper::headerTagger("Content-Type", "text/html", array('charset' => $this->getMailer()->getOption('charset'))) . Mailer::$LINE_ENDING;
         $this->message .= Mailer::$LINE_ENDING . trim($this->html, Mailer::$LINE_ENDING);
     }
     if ($bound) {
         $this->message .= Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary_ctt') . Mailer::BOUNDARY_CLOSER . Mailer::$LINE_ENDING;
     }
     // Attachments
     /* @todo what is max ? */
     $max = 10;
     if (count($this->attachment) > 0) {
         for ($i = 0; $i < $max; $i++) {
             if (isset($this->attachment[$i])) {
                 $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
                 $filename = basename($this->attachment[$i]);
                 $this->message .= Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary') . Mailer::$LINE_ENDING;
                 $this->message .= Helper::headerTagger("Content-Type", Helper::getMimeType($filename), array('name' => $filename, 'charset' => $this->getMailer()->getOption('charset'))) . Mailer::$LINE_ENDING;
                 $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "base64") . Mailer::$LINE_ENDING;
                 $this->message .= Helper::headerTagger("Content-Disposition", 'attachment', array('filename' => $filename)) . Mailer::$LINE_ENDING;
                 $this->message .= Helper::headerTagger("Content-Description", $filename) . Mailer::$LINE_ENDING;
                 $this->message .= Mailer::$LINE_ENDING . chunk_split(base64_encode($file));
                 $file = $filename = "";
             }
         }
         $this->message .= Mailer::$LINE_ENDING . Mailer::BOUNDARY_OPENER . $this->getMailer()->getRegistry('boundary') . Mailer::BOUNDARY_CLOSER . Mailer::$LINE_ENDING;
     }
     return $this;
 }