![]() |
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 - connect to MTA server (Gmail) via SSL (TLS encryption) 00025 - send mail relay using step-by-step SMTP commands 00026 */ 00027 00028 // manage errors 00029 error_reporting(E_ALL); // php errors 00030 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors 00031 00032 // path to 'SMTP.php' file from XPM4 package 00033 require_once '../SMTP.php'; 00034 00035 $f = 'username@gmail.com'; // from (Gmail mail address) 00036 $t = 'client@destination.net'; // to mail address 00037 $p = 'password'; // Gmail password 00038 00039 // standard mail message RFC2822 00040 $m = 'From: '.$f."\r\n". 00041 'To: '.$t."\r\n". 00042 'Subject: test'."\r\n". 00043 'Content-Type: text/plain'."\r\n\r\n". 00044 'Text message.'; 00045 00046 // connect to 'smtp.gmail.com' via SSL (TLS encryption) using port '465' and timeout '10' secounds 00047 // make sure you have OpenSSL module (extension) enable on your php configuration 00048 $c = fsockopen('tls://smtp.gmail.com', 465, $errno, $errstr, 10) or die($errstr); 00049 // expect response code '220' 00050 if (!SMTP::recv($c, 220)) die(print_r($_RESULT)); 00051 // EHLO/HELO 00052 if (!SMTP::ehlo($c, 'localhost')) SMTP::helo($c, 'localhost') or die(print_r($_RESULT)); 00053 // AUTH LOGIN/PLAIN 00054 if (!SMTP::auth($c, $f, $p, 'login')) SMTP::auth($c, $f, $p, 'plain') or die(print_r($_RESULT)); 00055 // MAIL FROM 00056 SMTP::from($c, $f) or die(print_r($_RESULT)); 00057 // RCPT TO 00058 SMTP::to($c, $t) or die(print_r($_RESULT)); 00059 // DATA 00060 SMTP::data($c, $m) or die(print_r($_RESULT)); 00061 // RSET, optional if you need to send another mail using this connection '$c' 00062 // SMTP::rset($c) or die(print_r($_RESULT)); 00063 // QUIT 00064 SMTP::quit($c); 00065 // close connection 00066 @fclose($c); 00067 00068 echo 'Sent !'; 00069 00070 ?>