/** * Assembles the message body. Returns a string if successful * or false if unsuccessful. * @private * @returns string */ function create_body() { $body = array(); // wordwrap the message body if set if ($this->WordWrap > 0) { $this->Body = $this->word_wrap($this->Body, $this->WordWrap); } switch ($this->message_type) { case "alt": // Return text of body $bndry = new Boundary($this->boundary[1]); $bndry->CharSet = $this->CharSet; $bndry->Encoding = $this->Encoding; $body[] = $bndry->GetSource(); $body[] = sprintf("%s%s", $this->AltBody, $this->LE . $this->LE); $bndry = new Boundary($this->boundary[1]); $bndry->CharSet = $this->CharSet; $bndry->ContentType = "text/html"; $bndry->Encoding = $this->Encoding; $body[] = $bndry->GetSource(); $body[] = sprintf("%s%s", $this->Body, $this->LE . $this->LE); // End the boundary $body[] = sprintf("%s--%s--%s", $this->LE, $this->boundary[1], $this->LE . $this->LE); break; case "plain": $body[] = $this->Body; break; case "attachments": $bndry = new Boundary($this->boundary[1]); $bndry->CharSet = $this->CharSet; $bndry->ContentType = $this->ContentType; $bndry->Encoding = $this->Encoding; $body[] = sprintf("%s%s%s%s", $bndry->GetSource(false), $this->LE, $this->Body, $this->LE); if (!($body[] = $this->attach_all())) { return false; } break; case "alt_attachments": $body[] = sprintf("--%s%s", $this->boundary[1], $this->LE); $body[] = sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", "multipart/alternative", $this->LE, $this->boundary[2], $this->LE . $this->LE); // Create text body $bndry = new Boundary($this->boundary[2]); $bndry->CharSet = $this->CharSet; $bndry->ContentType = "text/plain"; $bndry->Encoding = $this->Encoding; $body[] = $bndry->GetSource() . $this->LE; $body[] = sprintf("%s%s", $this->AltBody, $this->LE . $this->LE); // Create the HTML body $bndry = new Boundary($this->boundary[2]); $bndry->CharSet = $this->CharSet; $bndry->ContentType = "text/html"; $bndry->Encoding = $this->Encoding; $body[] = $bndry->GetSource() . $this->LE; $body[] = sprintf("%s%s", $this->Body, $this->LE . $this->LE); $body[] = sprintf("%s--%s--%s", $this->LE, $this->boundary[2], $this->LE . $this->LE); if (!($body[] = $this->attach_all())) { return false; } break; } // Add the encode string code here $sBody = join("", $body); $sBody = $this->encode_string($sBody, $this->Encoding); return $sBody; }