Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
mime-parse.php
Go to the documentation of this file.
1 <?php
2 
3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * XPertMailer is a PHP Mail Class that can send and read messages in MIME format. *
6  * This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/) *
7  * Copyright (C) 2007 Tanase Laurentiu Iulian *
8  * *
9  * This library is free software; you can redistribute it and/or modify it under the *
10  * terms of the GNU Lesser General Public License as published by the Free Software *
11  * Foundation; either version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY *
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
15  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public License along with *
18  * this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
19  * Fifth Floor, Boston, MA 02110-1301, USA *
20  * *
21  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22 
23 /* Purpose:
24  - compose a mail message in MIME format
25  - set 'text/plain' and 'text/html' (with embed image) version of message
26  - add an attachment 'file.txt' from source
27  - split mail source
28  - print result (headers and body parts)
29 */
30 
31 // manage errors
32 error_reporting(E_ALL); // php errors
33 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
34 
35 // path to 'MIME.php' file from XPM4 package
36 require_once '../MIME.php';
37 
38 // COMPOSE message ----------------------------------
39 $id = MIME::unique();
40 // set text/plain version of message
41 $text = MIME::message('Text version of message.', 'text/plain');
42 // set text/html version of message with an embed image
43 $html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">', 'text/html');
44 // add attachment with name 'file.txt'
45 $at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
46 $file = 'xpertmailer.gif';
47 // add inline attachment '$file' with name 'XPM.gif' and ID '$id'
48 $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id);
49 // compose mail message in MIME format
50 $mess = MIME::compose($text, $html, $at);
51 // standard mail message RFC2822
52 $mail = 'From: my@addr.com'."\r\n".
53  'To: me@addr.net'."\r\n".
54  'Subject: test'."\r\n".
55  $mess['header']."\r\n\r\n".
56  $mess['content'];
57 // die($mail); // << uncomment this line to see the mail source
58 
59 // SPLIT message ------------------------------------
60 $split = MIME::split_mail($mail, $headers, $body);
61 
62 // print results
63 echo '<br /><pre>MAIL HEADERS ####################################'."\n";
64 print_r($headers);
65 echo '<br />MAIL BODY PARTS #################################'."\n";
66 print_r($body);
67 echo '</pre>';
68 
69 ?>