how to automatically convert email into web page?

Discussion in 'Programming' started by quite, May 7, 2007.

  1. #1
    hey everyone, im new here.

    basically i want to be able to do the following:

    have a system set up which, when an email from a particular domain is recieved, it is converted into html and put into a database, with certain parameters set such as which domain it was from, what the subject line is etc.

    is this possible? and is their such a system available already?

    thanks
    joe
     
    quite, May 7, 2007 IP
  2. quite

    quite Peon

    Messages:
    392
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    any one please??

    if noone knows of such thing, anyone know about how easy it would be to develop?
     
    quite, May 10, 2007 IP
  3. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #3
    steps for your system in php
    - read email box with imap_xxxx functions
    - grab your email body (imap_xxxx)
    - then do whatever you want with it.

    	$mbox = imap_open("{domain.com:110/pop3}INBOX", "username", "password");
    	
    	if ($mbox != FALSE) {
    		
    		$nrMessages = imap_num_msg($mbox);
    		
    		for ($i=1; $i <= $nrMessages; $i++) {
    			
    			$body_header = imap_fetchbody($mbox, $i, '0');	
    			$body = imap_fetchbody($mbox, $i, '1');	
    			$bodyLines = split("\n", $body);
    			
    			echo $toEmail . "\n";
    				
    			// Delete this email
    			imap_delete($mbox, $i);
    		}
    
    		imap_expunge($mbox);	
    	}	
    PHP:
    I hope this help
     
    gibex, May 12, 2007 IP
  4. quite

    quite Peon

    Messages:
    392
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    im not particularly familar with php so sorry for the rather basic reply.

    Would by inserting that into a web page, would firstly it add the results into a mysql database?

    Is their a way of attaching a date to it?!

    If i was to test out that code, would i simply insert it into a webpage, and change the domain.com to my domain, and the login details would i be good to go?!

    thanks for your replys
    cheers
    joe
     
    quite, May 12, 2007 IP
  5. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I haven't worked with PHP's IMAP stuff, and it's been ages since I paid attention to mail handlers, so I can't comment on the questions you ask here.

    But there's one other piece you'll need: something to poll for the email. So, if you set that PHP script up as a command line app, you really should set up some sort of job to run that script periodically (however often you think you'll need to check the mail).

    If you put it into a web page, the same sort of thing applies. You'll have to refresh that page to check the mail.

    Depending on the big picture of what you want, and what you have available, there might be better ways to do this.
     
    jimrthy, May 13, 2007 IP
  6. Range

    Range Banned

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    Thanks fo this script.
    usefull
     
    Range, May 13, 2007 IP