Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
mail-client.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/plain' and 'text/html' version of message
25  - send mail directly to client (without MTA support)
26  - add attachment
27  - embed image into HTML
28  - print result
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 'MAIL.php' file from XPM4 package
36 require_once '../MAIL.php';
37 
38 // get ID value (random) for the embed image
39 $id = MIME::unique();
40 
41 // initialize MAIL class
42 $m = new MAIL;
43 // set from address and name
44 $m->From('me@myaddress.net', 'My Name');
45 // add to address and name
46 $m->AddTo('client@destination.net', 'Client Name');
47 // set subject
48 $m->Subject('Hello World!');
49 // set text/plain version of message
50 $m->Text('Text version of message.');
51 // set text/html version of message
52 $m->Html('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">');
53 // add attachment ('text/plain' file)
54 $m->Attach('source file', 'text/plain');
55 $f = 'xpertmailer.gif';
56 // add inline attachment '$f' file with ID '$id'
57 $m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'inline', $id);
58 
59 // send mail
60 echo $m->Send('client') ? 'Mail sent !' : 'Error !';
61 
62 // optional for debugging ----------------
63 echo '<br /><pre>';
64 // print History
65 print_r($m->History);
66 // calculate time
67 list($tm1, $ar1) = each($m->History[0]);
68 list($tm2, $ar2) = each($m->History[count($m->History)-1]);
69 echo 'The process took: '.(floatval($tm2)-floatval($tm1)).' seconds.</pre>';
70 
71 ?>