Bitcoin Forum
June 20, 2018, 03:33:31 AM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Wanted: PHP email parser  (Read 1746 times)
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



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
1529465611
Hero Member
*
Offline Offline

Posts: 1529465611

View Profile Personal Message (Offline)

Ignore
1529465611
Reply with quote  #2

1529465611
Report to moderator
The World's Betting Exchange

Bet with play money. Win real Bitcoin. 5BTC Prize Fund for World Cup 2018.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1529465611
Hero Member
*
Offline Offline

Posts: 1529465611

View Profile Personal Message (Offline)

Ignore
1529465611
Reply with quote  #2

1529465611
Report to moderator
1529465611
Hero Member
*
Offline Offline

Posts: 1529465611

View Profile Personal Message (Offline)

Ignore
1529465611
Reply with quote  #2

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

Activity: 812
Merit: 1000



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!