Hi Jeremy,
Yes that is possible. But i'm afraid it needs some work.

There are several classes on the several dowmload sites. Look for POP3 or 
IMAP classes. Some recent links at the end of this mail. With them it is 
possible to get the headers and the body either line by line or in total. It 
is possible to check mail and delete mail. You can log in to any email 
address you like by entering the host, username and password.

        
Regular checking must be done by starting a .php file (which reads email of course) 
from a timescheduler like cron on unix-type servers or with some other scheduler on 
windows or whatever you use. Check the archives of this php-general list for cron 
jobs, that question returns about every week.

> I suppose that it should have some sort of authentication built in to 
> prevent people from e-mailing PHP code that could be processed and 
> do bad things.
I don't know about security of strings, i just don't see when they can be activated, 
but it is worth digging in. Maybe htmlspecialchars($text) will do?

I was looking into this too because i would like to receive emails with data, 
process them and either enter data or return an error-reporting email.
About security i am most worried how to know whether the sender is really the 
sender. I mean, if i make them give their password every time, it could be 
intercepted. If i check by email address, i know it is only too easy to fake an 
email being sent from a certain email. Any idea? 

 
> Could the e-mail be written to a mail queue say
> [EMAIL PROTECTED] and the script periodically check the mail
> queue for new e-mail print its contents to a text file somewhere in the
> serverroot and then erase the mail queue???
> 
> Does this sound possibile???
Yes. But it will take quite some time making it solid bastard- and fool-proof.  
Writing to a file is normal file-processing once you have extracted the text you 
need from the email. 


Maybe we can cooperate building a class? There are pop3 classes around that could be 
extended with some functions i suppose more people can use.

What about making this:  (just brainstorming)

/* build further on an existing pop3 class :  
  function connect {connect using pop_3_class}
  function disconnect {disconnect using pop_3_class}
  function getonemail 
*/


class email {
  vars $sender, $subject, $body, $emailID_for_POP3                      

        function read_one_mail()
                        sets $header, $body, $sender
                        or if you like $body_lines_array
                        maybe even attachments?

        function validate_user()    
                        compares email to database of authorised users
                        for instance 1) find password and username in body, 
                                                2) compare to database
                                                3) accept or reject (log possible 
frauds with full headers)

        function split_up_body_to_data()
                        because i want to chop up a data mail which may look like
                        [name]Chris
                        [password]Cookies!
                        [announcement_title]Come to my party!
                        [announcement_date]July 11 2001
                        [announcement_body]Be welcome to my party! I'll have cookies!
                        [end]
                 I want to get this into an kay-val array and 
                 further check in another part, maybe return a mail with error,
                and on succes i can use:        

        function delete_mail(this_one)
                
}





I have some links, without having tested them all:

        *       http://home.concepts.nl/~kid/phpmanual/sockets.html 

        *       pop3.php Copyright (C) 1998, Manuel Lemos ([EMAIL PROTECTED])
                (I think i saw Manuel on this list! :-) )
                Also it looks the most structured and general.
                I forgot where, maybe the px.sklar.com site.

        *       pop3_connect on http://phpclub.unet.ru/samples/73.phps

        * http://www.weberdev.com/get_example.php3?count=1643

        * http://px.sklar.com/code-pretty.html?code_id=108
        * http://px.sklar.com/code-pretty.html?code_id=139


PS there might be Perl codes around doing something similar to what you want.


Chris Hayes



--------------------------------------------------------------------
--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --
--------------------------------------------------------------------

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to