1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
use BounceMailHandler\BounceMailHandler; |
4
|
|
|
|
5
|
|
|
/*~ index.php |
6
|
|
|
.---------------------------------------------------------------------------. |
7
|
|
|
| Software: PHPMailer-BMH (Bounce Mail Handler) | |
8
|
|
|
| Version: 5.3-dev | |
9
|
|
|
| Contact: [email protected] | |
10
|
|
|
| Info: http://phpmailer.codeworxtech.com | |
11
|
|
|
| ------------------------------------------------------------------------- | |
12
|
|
|
| Author: Andy Prevost [email protected] (admin) | |
13
|
|
|
| Copyright (c) 2002-2009, Andy Prevost. All Rights Reserved. | |
14
|
|
|
| ------------------------------------------------------------------------- | |
15
|
|
|
| License: Distributed under the General Public License (GPL) | |
16
|
|
|
| (http://www.gnu.org/licenses/gpl.html) | |
17
|
|
|
| This program is distributed in the hope that it will be useful - WITHOUT | |
18
|
|
|
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19
|
|
|
| FITNESS FOR A PARTICULAR PURPOSE. | |
20
|
|
|
| ------------------------------------------------------------------------- | |
21
|
|
|
| This is a update of the original Bounce Mail Handler script | |
22
|
|
|
| http://sourceforge.net/projects/bmh/ | |
23
|
|
|
| The script has been renamed from Bounce Mail Handler to PHPMailer-BMH | |
24
|
|
|
| ------------------------------------------------------------------------- | |
25
|
|
|
| We offer a number of paid services: | |
26
|
|
|
| - Web Hosting on highly optimized fast and secure servers | |
27
|
|
|
| - Technology Consulting | |
28
|
|
|
| - Oursourcing (highly qualified programmers and graphic designers) | |
29
|
|
|
'---------------------------------------------------------------------------' |
30
|
|
|
|
31
|
|
|
/* |
32
|
|
|
* This is an example script to work with PHPMailer-BMH (Bounce Mail Handler). |
33
|
|
|
*/ |
34
|
|
|
|
35
|
|
|
$time_start = microtime_float(); |
36
|
|
|
|
37
|
|
|
require_once '../vendor/autoload.php'; |
38
|
|
|
|
39
|
|
|
// Use ONE of the following -- all echo back to the screen |
40
|
|
|
|
41
|
|
|
//require_once 'callback_echo.php'; |
|
|
|
|
42
|
|
|
//require_once('callback_database.php'); // NOTE: Requires modification to insert your database settings |
43
|
|
|
//require_once('callback_csv.php'); // NOTE: Requires creation of a 'logs' directory and making writable |
44
|
|
|
|
45
|
|
|
// testing examples |
46
|
|
|
$bmh = new BounceMailHandler(); |
47
|
|
|
$bmh->actionFunction = 'callbackAction'; // default is 'callbackAction' |
48
|
|
|
$bmh->verbose = BounceMailHandler::VERBOSE_SIMPLE; //BounceMailHandler::VERBOSE_SIMPLE; //BounceMailHandler::VERBOSE_REPORT; //BounceMailHandler::VERBOSE_DEBUG; //BounceMailHandler::VERBOSE_QUIET; // default is BounceMailHandler::VERBOSE_SIMPLE |
|
|
|
|
49
|
|
|
//$bmh->useFetchStructure = true; // true is default, no need to specify |
50
|
|
|
//$bmh->testMode = false; // false is default, no need to specify |
51
|
|
|
//$bmh->debugBodyRule = false; // false is default, no need to specify |
52
|
|
|
//$bmh->debugDsnRule = false; // false is default, no need to specify |
53
|
|
|
//$bmh->purgeUnprocessed = false; // false is default, no need to specify |
54
|
|
|
$bmh->disableDelete = true; // false is default, no need to specify |
55
|
|
|
|
56
|
|
|
/* |
57
|
|
|
* for local mailbox (to process .EML files) |
58
|
|
|
*/ |
59
|
|
|
//$bmh->openLocal('/home/email/temp/mailbox'); |
|
|
|
|
60
|
|
|
//$bmh->processMailbox(); |
61
|
|
|
|
62
|
|
|
/* |
63
|
|
|
* for remote mailbox |
64
|
|
|
*/ |
65
|
|
|
$bmh->mailhost = ''; // your mail server |
66
|
|
|
$bmh->mailboxUserName = ''; // your mailbox username |
67
|
|
|
$bmh->mailboxPassword = ''; // your mailbox password |
68
|
|
|
$bmh->port = 143; // the port to access your mailbox, default is 143 |
69
|
|
|
$bmh->service = 'imap'; // the service to use (imap or pop3), default is 'imap' |
70
|
|
|
$bmh->serviceOption = 'notls'; // the service options (none, tls, notls, ssl, etc.), default is 'notls' |
71
|
|
|
$bmh->boxname = 'INBOX'; // the mailbox to access, default is 'INBOX' |
72
|
|
|
|
73
|
|
|
//$bmh->moveHard = true; // default is false |
|
|
|
|
74
|
|
|
//$bmh->hardMailbox = 'INBOX.hardtest'; // default is 'INBOX.hard' - NOTE: must start with 'INBOX.' |
75
|
|
|
//$bmh->moveSoft = true; // default is false |
76
|
|
|
//$bmh->softMailbox = 'INBOX.softtest'; // default is 'INBOX.soft' - NOTE: must start with 'INBOX.' |
77
|
|
|
//$bmh->deleteMsgDate = '2009-01-05'; // format must be as 'yyyy-mm-dd' |
78
|
|
|
|
79
|
|
|
/* |
80
|
|
|
* rest used regardless what type of connection it is |
81
|
|
|
*/ |
82
|
|
|
$bmh->openMailbox(); |
83
|
|
|
$bmh->processMailbox(); |
84
|
|
|
|
85
|
|
|
echo '<hr style="width:200px;" />'; |
86
|
|
|
$time_end = microtime_float(); |
87
|
|
|
$time = $time_end - $time_start; |
88
|
|
|
echo 'Seconds to process: ' . $time . '<br />'; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return float |
92
|
|
|
*/ |
93
|
|
|
function microtime_float() |
94
|
|
|
{ |
95
|
|
|
list($usec, $sec) = explode(' ', microtime()); |
96
|
|
|
|
97
|
|
|
return ((float)$usec + (float)$sec); |
98
|
|
|
} |
99
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.