Xataface Email Module 0.2
Email/Mailmerge Module for Xataface
lib/XPM/EXAMPLES/mime-parse.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    - compose a mail message in MIME format
00025    - set 'text/plain' and 'text/html' (with embed image) version of message
00026    - add an attachment 'file.txt' from source
00027    - split mail source
00028    - print result (headers and body parts)
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 'MIME.php' file from XPM4 package
00036 require_once '../MIME.php';
00037 
00038 // COMPOSE message ----------------------------------
00039 $id = MIME::unique();
00040 // set text/plain version of message
00041 $text = MIME::message('Text version of message.', 'text/plain');
00042 // set text/html version of message with an embed image
00043 $html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">', 'text/html');
00044 // add attachment with name 'file.txt'
00045 $at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
00046 $file = 'xpertmailer.gif';
00047 // add inline attachment '$file' with name 'XPM.gif' and ID '$id'
00048 $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id);
00049 // compose mail message in MIME format
00050 $mess = MIME::compose($text, $html, $at);
00051 // standard mail message RFC2822
00052 $mail = 'From: my@addr.com'."\r\n".
00053                 'To: me@addr.net'."\r\n".
00054                 'Subject: test'."\r\n".
00055                 $mess['header']."\r\n\r\n".
00056                 $mess['content'];
00057 // die($mail); // << uncomment this line to see the mail source
00058 
00059 // SPLIT message ------------------------------------
00060 $split = MIME::split_mail($mail, $headers, $body);
00061 
00062 // print results
00063 echo '<br /><pre>MAIL HEADERS ####################################'."\n";
00064 print_r($headers);
00065 echo '<br />MAIL BODY PARTS #################################'."\n";
00066 print_r($body);
00067 echo '</pre>';
00068 
00069 ?>
 All Data Structures Files Functions Variables Enumerations