![]() |
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 HTML message 00025 - send mail relay using Gmail MTA via SSL (TLS encryption) and authentication 00026 - print result 00027 */ 00028 00029 // manage errors 00030 error_reporting(E_ALL); // php errors 00031 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors 00032 00033 // path to 'MAIL.php' file from XPM4 package 00034 require_once '../MAIL.php'; 00035 00036 // initialize MAIL class 00037 $m = new MAIL; 00038 // set from address 00039 $m->From('username@gmail.com'); 00040 // add to address 00041 $m->AddTo('client@destination.net'); 00042 // set subject 00043 $m->Subject('Hello World!'); 00044 // set HTML message 00045 $m->Html('<b>HTML</b> <u>message</u>.'); 00046 00047 // connect to MTA server 'smtp.gmail.com' port '465' via SSL ('tls' encryption) with authentication: 'username@gmail.com'/'password' 00048 // set the connection timeout to 10 seconds, the name of your host 'localhost' and the authentication method to 'plain' 00049 // make sure you have OpenSSL module (extension) enable on your php configuration 00050 $c = $m->Connect('smtp.gmail.com', 465, 'username@gmail.com', 'password', 'tls', 10, 'localhost', null, 'plain') or die(print_r($m->Result)); 00051 00052 // send mail relay using the '$c' resource connection 00053 echo $m->Send($c) ? 'Mail sent !' : 'Error !'; 00054 00055 // disconnect from server 00056 $m->Disconnect(); 00057 00058 // optional for debugging ---------------- 00059 echo '<br /><pre>'; 00060 // print History 00061 print_r($m->History); 00062 // calculate time 00063 list($tm1, $ar1) = each($m->History[0]); 00064 list($tm2, $ar2) = each($m->History[count($m->History)-1]); 00065 echo 'The process took: '.(floatval($tm2)-floatval($tm1)).' seconds.</pre>'; 00066 00067 ?>