/**
  * aldonas dosieron kreita enmemore.
  * 
  * @param string $enhavo la enhavo de la dosiero (kiel bitoka cxeno).
  * @param string $nomo   la dosiernomo por nomi la aldonajxon. 
  * @param string $tipo   la enhavtipo. Se ne donita, ni provos diveni gxin
  *                        laux la nomo de la dosiero.
  */
 function aldonu_dosieron_el_memoro($enhavo, $nomo, $tipo = "")
 {
     $datoj = array('Data' => $enhavo, 'Name' => $nomo, 'Content-Type' => $tipo ? $tipo : 'automatic/name');
     $eraro = $this->baza_objekto->AddFilePart($datoj);
     $this->testu_eraron($eraro);
 }
$email_message->SetHeader("Sender", $from_address);
/*
 *  Set the Return-Path header to define the envelope sender address to which bounced messages are delivered.
 *  If you are using Windows, you need to use the smtp_message_class to set the return-path address.
 */
if (defined("PHP_OS") && strcmp(substr(PHP_OS, 0, 3), "WIN")) {
    $email_message->SetHeader("Return-Path", $error_delivery_address);
}
$email_message->SetEncodedHeader("Subject", $subject);
/*
 *  A message with attached files usually has a text message part
 *  followed by one or more attached file parts.
 */
$text_message = "Hello " . strtok($to_name, " ") . "\n\nThis message is just to let you know that the MIME E-mail message composing and sending PHP class is working as expected.\n\nYou may find attached to this messages a text file and and image file.\n\nThank you,\n{$from_name}";
$email_message->AddQuotedPrintableTextPart($email_message->WrapText($text_message));
$text_attachment = array("Data" => "This is just a plain text attachment file named attachment.txt .", "Name" => "attachment.txt", "Content-Type" => "automatic/name", "Disposition" => "attachment");
$email_message->AddFilePart($text_attachment);
$image_attachment = array("FileName" => "http://www.phpclasses.org/graphics/logo.gif", "Content-Type" => "automatic/name", "Disposition" => "attachment");
$email_message->AddFilePart($image_attachment);
/*
 *  The message is now ready to be assembled and sent.
 *  Notice that most of the functions used before this point may fail due to
 *  programming errors in your script. You may safely ignore any errors until
 *  the message is sent to not bloat your scripts with too much error checking.
 */
$error = $email_message->Send();
if (strcmp($error, "")) {
    echo "Error: {$error}\n";
} else {
    echo "Message sent to {$to_name}\n";
}
 *  Multiple alternative parts are gathered in multipart/alternative parts.
 *  It is important that the fanciest part, in this case the HTML part,
 *  is specified as the last part because that is the way that HTML capable
 *  mail programs will show that part and not the text version part.
 */
$alternative_parts = array($text_part, $html_part);
$email_message->CreateAlternativeMultipart($alternative_parts, $alternative_part);
/*
 *  All related parts are gathered in a single multipart/related part.
 */
$related_parts = array($alternative_part, $image_part, $background_image_part);
$email_message->AddRelatedMultipart($related_parts);
/*
 *  One or more additional parts may be added as attachments.
 *  In this case a file part is added from data provided directly from this script.
 */
$attachment = array("Data" => "This is just a plain text attachment file named attachment.txt .", "Name" => "attachment.txt", "Content-Type" => "automatic/name", "Disposition" => "attachment");
$email_message->AddFilePart($attachment);
/*
 *  The message is now ready to be assembled and sent.
 *  Notice that most of the functions used before this point may fail due to
 *  programming errors in your script. You may safely ignore any errors until
 *  the message is sent to not bloat your scripts with too much error checking.
 */
$error = $email_message->Send();
if (strcmp($error, "")) {
    echo "Error: {$error}\n";
} else {
    echo "Message sent to {$to_name}\n";
}
var_dump($email_message->parts);
/**
 * Sendas mesagxon kun aldonitaj dosieroj.
 *
 * $subjekto    - temlinio
 * $korpo		- mesagxteksto
 * $to_name		- nomo de la ricevonto
 * $to_adress   - adreso de la ricevonto
 * $dosierojn   - array() kun la nomoj de
 *                la dosieroj, kiuj aldonendas.
 * $bcc_address - adreso, al kiu sendigxu sekreta kopio.
 *
 * ### uzata de specialaj_skriptoj/... kaj
 * ###          sendu_2ankonfirmilon() (sube). ###
 */
function sendu_dosier_mesagxon($subjekto, $korpo, $to_name, $to_address, $dosierojn = array(), $bcc_address = '')
{
    // TODO: purigu la implementon de sendu_dosier_mesagxon
    // TODO: gxeneraligu la sendinto-nomon kaj -adreson!
    $subject = utf8_decode($subjekto);
    //  $mesagxo  = "### auxtomata mesagxo de la DEJ-aligilo ###\n\n";
    //  $mesagxo .= utf8_decode($korpo);
    $mesagxo .= $korpo;
    $mesagxo .= "\n\n### Se estas iu teknika problemo, bonvolu informi Paul.Ebermann@esperanto.de ###";
    //   $from_name = "KKRen (Pauxlo Ebermann)";
    //   $from_address = "*****@*****.**";
    //   $from_address = "*****@*****.**";
    //   $respondo_nomo = "IS-Enketo";
    //   $respondo_adreso = "*****@*****.**";
    $from_name = "IS-Administranto";
    $from_address = "*****@*****.**";
    $respondo_nomo = "IS-Administranto";
    $respondo_adreso = "*****@*****.**";
    $email_message = new email_message_class();
    $email_message->default_charset = "UTF-8";
    if ($bcc_address) {
        $bcc_address .= ", Paul.Ebermann@esperanto.de";
    } else {
        $bcc_address = "*****@*****.**";
    }
    echo "BCC: " . $bcc_address . "\n";
    if (!strcmp($error = $email_message->SetEncodedEmailHeader("To", $to_address, utf8_decode($to_name)), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("From", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("BCC", $bcc_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("Reply-To", $respondo_adreso, $respondo_nomo), "") && !strcmp($error = $email_message->SetEncodedHeader("Errors-To", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedHeader("Subject", $subject), "") && !strcmp($error = $email_message->AddQuotedPrintableTextPart($email_message->WrapText($mesagxo)), "")) {
        for ($i = sizeof($dosierojn) - 1; $i >= 0; $i--) {
            $attachment = array("FileName" => $dosierojn[$i], "Content-Type" => "automatic/name");
            $email_message->AddFilePart($attachment);
        }
    }
    $error = $email_message->Send();
    if ($error) {
        erareldono($error);
        exit;
    }
}