public
Fork of economysizegeek/postie
Description: A plugin for WordPress that makes mobloging and blogging by email much much better
Homepage: http://postie.economysizegeek.com/
Clone URL: git://github.com/tedkulp/postie.git
Search Repo:
postie / get_mail.php
100644 50 lines (42 sloc) 1.362 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/php -q
<?php
 
//Load up some usefull libraries
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-config.php");
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'mimedecode.php');
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'postie-functions.php');
  
if (!TestWPVersion()) {
    print("<p>Postie Only Works For Word Press 2.0 and above.</p>");
    exit();
}
 
/* END OF USER VARIABLES */
//some variables
error_reporting(2037);
TestWPMailInstallation();
 
//Retreive emails
print("<pre>\n");
$emails = FetchMail();
//loop through messages
foreach ($emails as $email) {
    //sanity check to see if there is any info in the message
    if ($email == NULL ) { print 'Dang, message is empty!'; continue; }
    
    $mimeDecodedEmail = DecodeMimeMail($email);
    $from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
    /*
if ($from != "") {
continue;
}
*/
 
    //Check poster to see if a valid person
    $poster = ValidatePoster($mimeDecodedEmail);
    if (!empty($poster)) {
        DebugEmailOutput($email,$mimeDecodedEmail);
        PostEmail($poster,$mimeDecodedEmail);
    }
    else {
        print("<p>Ignoring email - not authorized.\n");
    }
} // end looping over messages
print("</pre>\n");
    
/* END PROGRAM */
 
// end of script
?>