Xataface Email Module 0.3
Email/Mailmerge Module for Xataface
lib/XPM/EXAMPLES/mail-client.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  *                                                                                         *
00005  *  XPertMailer is a PHP Mail Class that can send and read messages in MIME format.        *
00006  *  This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/)     *
00007  *  Copyright (C) 2007 Tanase Laurentiu Iulian                                             *
00008  *                                                                                         *
00009  *  This library is free software; you can redistribute it and/or modify it under the      *
00010  *  terms of the GNU Lesser General Public License as published by the Free Software       *
00011  *  Foundation; either version 2.1 of the License, or (at your option) any later version.  *
00012  *                                                                                         *
00013  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A        *
00015  *  PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.        *
00016  *                                                                                         *
00017  *  You should have received a copy of the GNU Lesser General Public License along with    *
00018  *  this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  *  Fifth Floor, Boston, MA 02110-1301, USA                                                *
00020  *                                                                                         *
00021  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00022 
00023 /* Purpose:
00024    - set 'text/plain' and 'text/html' version of message
00025    - send mail directly to client (without MTA support)
00026    - add attachment
00027    - embed image into HTML
00028    - print result
00029 */
00030 
00031 // manage errors
00032 error_reporting(E_ALL); // php errors
00033 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
00034 
00035 // path to 'MAIL.php' file from XPM4 package
00036 require_once '../MAIL.php';
00037 
00038 // get ID value (random) for the embed image
00039 $id = MIME::unique();
00040 
00041 // initialize MAIL class
00042 $m = new MAIL;
00043 // set from address and name
00044 $m->From('me@myaddress.net', 'My Name');
00045 // add to address and name
00046 $m->AddTo('client@destination.net', 'Client Name');
00047 // set subject
00048 $m->Subject('Hello World!');
00049 // set text/plain version of message
00050 $m->Text('Text version of message.');
00051 // set text/html version of message
00052 $m->Html('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">');
00053 // add attachment ('text/plain' file)
00054 $m->Attach('source file', 'text/plain');
00055 $f = 'xpertmailer.gif';
00056 // add inline attachment '$f' file with ID '$id'
00057 $m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'inline', $id);
00058 
00059 // send mail
00060 echo $m->Send('client') ? 'Mail sent !' : 'Error !';
00061 
00062 // optional for debugging ----------------
00063 echo '<br /><pre>';
00064 // print History
00065 print_r($m->History);
00066 // calculate time
00067 list($tm1, $ar1) = each($m->History[0]);
00068 list($tm2, $ar2) = each($m->History[count($m->History)-1]);
00069 echo 'The process took: '.(floatval($tm2)-floatval($tm1)).' seconds.</pre>';
00070 
00071 ?>
 All Data Structures Files Functions Variables Enumerations