Using the PHP imap() function

Discussion in 'Web Programming' started by denny8569, Feb 12, 2010.

Using the PHP imap() function
  1. Unread #1 - Feb 12, 2010 at 4:40 AM
  2. denny8569
    Joined:
    Feb 12, 2010
    Posts:
    3
    Referrals:
    0
    Sythe Gold:
    0

    denny8569 Newcomer

    Using the PHP imap() function

    Ok here's what I want to do.. I want to write a script that will automatically catch all emails and auto-respond based on what is in the content of the email... For example I know how to create auto-responders but they send the same email everytime.. I want a script that first off checks the email account (imap()) and then responds based on the user email... eventually I would like to turn my server into a text sending server sending texts to cellphones (I can do that already) but I want it so users can send in a question from their phone and the server will answer them back correctly.

    Any thoughts on how to go about doing this?
     
  3. Unread #2 - Feb 13, 2010 at 11:27 PM
  4. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    Using the PHP imap() function

    Code:
    $connection = imap_open('{$server}', $login, $password);
    $count = imap_num_msg($connection);
    for($i = 1; $i <= $count; $i++) {
        $header = imap_headerinfo($connection, $i);
        $raw_body = imap_body($connection, $i);
        Respond($header, $raw_body);
        imap_delete(($connection, $i); // Or archive
    }
    Respond would get the email to reply to while reading the body of the email.

    explode / preg_match to get the parts you want. Respond to keywords or whatever you want to do.
    Add in a cronjob to make it automated, and you're done.
     
< [PHP]MSN Groups Clone [OpenSource] | My new project >

Users viewing this thread
1 guest


 
 
Adblock breaks this site