Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
pop3-smtp.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  - send mail using POP before SMTP (Mail Proxy) method
25 */
26 
27 // manage errors
28 error_reporting(E_ALL); // php errors
29 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
30 
31 // path to 'POP3.php' and 'SMTP.php' files from XPM4 package
32 require_once '../POP3.php';
33 require_once '../SMTP.php';
34 
35 $f = 'username@hostname.net'; // from mail address / account username
36 $t = 'client@destination.net'; // to mail address
37 $p = 'password'; // account password
38 
39 // standard mail message RFC2822
40 $m = 'From: '.$f."\r\n".
41  'To: '.$t."\r\n".
42  'Subject: test'."\r\n".
43  'Content-Type: text/plain'."\r\n\r\n".
44  'Text message.';
45 
46 // connect to 'pop3.hostname.net' POP3 server address with authentication username '$f' and password '$p'
47 $p = POP3::Connect('pop3.hostname.net', $f, $p) or die(print_r($_RESULT));
48 // connect to 'smtp.hostname.net' SMTP server address
49 $c = SMTP::Connect('smtp.hostname.net') or die(print_r($_RESULT));
50 
51 // send mail
52 $s = SMTP::Send($c, array($t), $m, $f);
53 
54 // print result
55 if ($s) echo 'Sent !';
56 else print_r($_RESULT);
57 
58 // disconnect from SMTP server
59 SMTP::Disconnect($c);
60 // disconnect from POP3 server
61 POP3::Disconnect($p);
62 
63 ?>