![]() |
Xataface Email Module 0.3
Email/Mailmerge Module for Xataface
|
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 and HTML version of message 00025 - add attachment 00026 - embed image into HTML 00027 */ 00028 00029 // manage errors 00030 error_reporting(E_ALL); // php errors 00031 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors 00032 //define('LOG_XPM4_ERRORS', serialize(array('type' => 1, 'destination' => 'errors@domain.tld', 'headers' => 'From: xpm4@domain.tld'))); // <- send mail 00033 //define('LOG_XPM4_ERRORS', serialize(array('type' => 3, 'destination' => '/var/tmp/XPM4.log'))); // <- append file 00034 00035 // path to 'MIME.php' file from XPM4 package 00036 require_once '../MIME.php'; 00037 00038 // get ID value (random) for the embed image 00039 $id = MIME::unique(); 00040 00041 // set text/plain version of message 00042 $text = MIME::message('Text version of message.', 'text/plain'); 00043 // set text/html version of message 00044 $html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:'.$id.'">', 'text/html'); 00045 // add attachment with name 'file.txt' 00046 $at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment'); 00047 $file = 'xpertmailer.gif'; 00048 // add inline attachment '$file' with name 'XPM.gif' and ID '$id' 00049 $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id); 00050 00051 // compose mail message in MIME format 00052 $mess = MIME::compose($text, $html, $at); 00053 00054 // send mail 00055 $send = mail('client@destination.net', 'Hello World!', $mess['content'], 'From: me@myaddress.net'."\n".$mess['header']); 00056 00057 // print result 00058 echo $send ? 'Sent !' : 'Error !'; 00059 00060 ?>