private function buildMsg() {

		if(isset($this->boundary)) {
			$this->msg = '--' . $this->boundary . self::CRLF;
			$this->msg .= 'Content-type: text/' . ($this->htmlMail ? 'html' : 'plain') . '; charset=' .$this->encoding . self::CRLF;
			$this->msg .= 'Content-Transfer-Encoding: 8bit' . self::CRLF . self::CRLF;
		}
		else {
			$this->msg = '';
		}

		$this->msg .= $this->mailText . self::CRLF;
		
		// add signature

		if(!empty($this->sig) && !$this->htmlMail) {
			$this->msg .= self::CRLF . self::CRLF . '-- ' . self::CRLF . $this->sig;
		}
			
		if(!count($this->attachments)) {
			$this->msg .= self::CRLF;
		}
		else {

			foreach($this->attachments as $f) {

			    // attached data always has a filename set

				$filename = empty($f['filename']) ? basename($f['path']) : $f['filename'];
	
				$this->msg .= self::CRLF . '--' . $this->boundary . self::CRLF;
				$this->msg .= sprintf('Content-Type: application/octet-stream; name="%s"', $filename) . self::CRLF;
				$this->msg .= sprintf('Content-Disposition: attachment; filename="%s"', $filename) . self::CRLF;
				$this->msg .= 'Content-Transfer-Encoding: base64' . self::CRLF . self::CRLF;

				if(isset($f['data'])) {
                    $this->msg .= rtrim(chunk_split(base64_encode($f['data']), 72, self::CRLF));
                }
				else {
                    $this->msg .= rtrim(chunk_split(base64_encode(file_get_contents($f['path'])), 72, self::CRLF));
                }
	
			}
			
			$this->msg .= self::CRLF . '--'. $this->boundary . '--' . self::CRLF;

		}
	}