Author

Topic: Wanted: PHP email parser (Read 1865 times)

hero member
Activity: 812
Merit: 1000
October 04, 2011, 11:24:36 PM
#2
thanks very much for the code, bitsky.

here it is in case anyone else finds it helpful:

Code:
#!/usr/bin/php

$mbox=imap_open('{mail.mymaildomain.com:110/pop3}INBOX', '[email protected]', 'mypassword') or die('POP3 connection failed');
$mails=imap_num_msg($mbox);
echo $mails." new mails arrived\n";
for ($i=1; $i<=$mails; $i++)
        {
        $mbody=imap_body($mbox, $i);
        $lines=explode("\n", $mbody);
        foreach ($lines as $tmp)
                {
                $tmp=trim($tmp);
                if (empty($tmp)) { continue; }
                echo "BODY[".$tmp."]\n";
                }
#       imap_delete($mbox, $i);
        }
#imap_expunge($mbox);
imap_close($mbox);

?>

basically i set up a new pop box, and a cron to run this script every 10 minutes.

edit: i tested the delete/expunge commands too and it works fine, thanks Cheesy
hero member
Activity: 812
Merit: 1000
October 04, 2011, 06:44:43 AM
#1
i'd like a php script which can take input from an email.

for example, i email [email protected] with the following:

blahblah
123
blah

the script then saves this to a text file or db <-- you don't actually need to give me this part as long as i can see clearly some variables in the script that contain the various email components.

preferably stripped down and simple as possible code.
preferably procedural code, not oop.

instructions/help to get it installed under debian.

thanks Cheesy
Jump to: