Bitcoin Forum
May 14, 2024, 12:15:23 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Wanted: PHP email parser  (Read 1843 times)
payb.tc (OP)
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
"The nature of Bitcoin is such that once version 0.1 was released, the core design was set in stone for the rest of its lifetime." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715688923
Hero Member
*
Offline Offline

Posts: 1715688923

View Profile Personal Message (Offline)

Ignore
1715688923
Reply with quote  #2

1715688923
Report to moderator
1715688923
Hero Member
*
Offline Offline

Posts: 1715688923

View Profile Personal Message (Offline)

Ignore
1715688923
Reply with quote  #2

1715688923
Report to moderator
1715688923
Hero Member
*
Offline Offline

Posts: 1715688923

View Profile Personal Message (Offline)

Ignore
1715688923
Reply with quote  #2

1715688923
Report to moderator
payb.tc (OP)
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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!