Location: PHPKode > scripts > XS PHP Library > xs-php-library/src/mwriter.php
<?php
//
// +--------------------------------------------------------------------------+
// |                                                                          |
// |                   XS PHP Library  Generic Classes Library                |
// |                                                                          |
// |                   Copyright (c) 2001-2002 XSPHPLib Group.                |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Distributed under the terms of the GNU Lesser General Public License as  |
// | published by the Free Software Foundation version 2.1                    |
// | See the GNU Lesser General Public License for more details. You should   |
// | have received a copy of the GNU Lesser General Public License along with |
// | this package; if not, write to the Free Software Foundation, Inc.,       |
// | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Authors: Robert Bala <hide@address.com>                                   |
// |                                                                          |
// +--------------------------------------------------------------------------+
//
// $Id: mwriter.php,v 1.2 2002/11/28 09:51:38 rbala Exp $

include_once('../inc/object.inc.php');
include_once('../inc/mime.inc.php');
include_once('../inc/mail.inc.php');
include_once('../inc/socket.inc.php');
include_once('../inc/smtp.inc.php');
include_once('../inc/mailwriter.inc.php');

// SMTP server.
$host = 'localhost';

// Sender email address.
$semail = 'hide@address.com';

// Recipient email address.
$remail = 'hide@address.com';

$message = new Mail('multipart', 'mixed');

object_checkError($message->setFrom($semail));
object_checkError($message->setTo($remail));

$message->setSubject('Sample MIME message');

$message->setHeader('x-mailer', 'Sample mailer');

$subpart1 =& $message->addMimePart('part1', 'text', 'plain');

$subpart1->setEncoding(MIME_ENCODING_7BIT);

$subpart1->setMimeParam('charset', 'iso-8859-1');
$subpart1->setContent('This is Subpart text message body....');
$subpart1->setDescription('Sample text message.');

$subpart2 =& $message->addMimePart('part2', 'text', 'plain');

$subpart2->setEncoding(MIME_ENCODING_BASE64);

$subpart2->setMimeParam('filename', 'README');
$subpart2->setContent('../README');
$subpart2->setDescription('Sample attached file.');

$subpart2->setDisposition('attachment');

$reader = new MailWriter($host);

$result = $reader->open();

if (object_isError($result)) {
    die($result->getMessage());
}

$result = $reader->write($message);

if (!object_isError($result)) {
    echo "Message has been sent....";
} else {
    echo $result->getMessage();
}

$reader->close();

?>
Return current item: XS PHP Library