Bitcoin Forum
February 27, 2017, 06:25:57 PM *
News: Latest stable version of Bitcoin Core: 0.13.2  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Wanted: PHP email parser  (Read 1693 times)
payb.tc
Hero Member
*****
Offline Offline

Activity: 812



View Profile
October 04, 2011, 11:44:43 AM
 #1

i'd like a php script which can take input from an email.

for example, i email phpscript@example.com 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
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1488219957
Hero Member
*
Offline Offline

Posts: 1488219957

View Profile Personal Message (Offline)

Ignore
1488219957
Reply with quote  #2

1488219957
Report to moderator
1488219957
Hero Member
*
Offline Offline

Posts: 1488219957

View Profile Personal Message (Offline)

Ignore
1488219957
Reply with quote  #2

1488219957
Report to moderator
payb.tc
Hero Member
*****
Offline Offline

Activity: 812



View Profile
October 05, 2011, 04:24:36 AM
 #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', 'user@mymaildomain.com', '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
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!