Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
mime-local.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  - set Text and HTML version of message
25  - add attachment
26  - embed image into HTML
27 */
28 
29 // manage errors
30 error_reporting(E_ALL); // php errors
31 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
32 //define('LOG_XPM4_ERRORS', serialize(array('type' => 1, 'destination' => 'errors@domain.tld', 'headers' => 'From: xpm4@domain.tld'))); // <- send mail
33 //define('LOG_XPM4_ERRORS', serialize(array('type' => 3, 'destination' => '/var/tmp/XPM4.log'))); // <- append file
34 
35 // path to 'MIME.php' file from XPM4 package
36 require_once '../MIME.php';
37 
38 // get ID value (random) for the embed image
39 $id = MIME::unique();
40 
41 // set text/plain version of message
42 $text = MIME::message('Text version of message.', 'text/plain');
43 // set text/html version of message
44 $html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">', 'text/html');
45 // add attachment with name 'file.txt'
46 $at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
47 $file = 'xpertmailer.gif';
48 // add inline attachment '$file' with name 'XPM.gif' and ID '$id'
49 $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id);
50 
51 // compose mail message in MIME format
52 $mess = MIME::compose($text, $html, $at);
53 
54 // send mail
55 $send = mail('client@destination.net', 'Hello World!', $mess['content'], 'From: me@myaddress.net'."\n".$mess['header']);
56 
57 // print result
58 echo $send ? 'Sent !' : 'Error !';
59 
60 ?>