Adblock breaks this site

Using the PHP imap() function

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

  1. denny8569

    denny8569 Newcomer

    Joined:
    Feb 12, 2010
    Posts:
    3
    Referrals:
    0
    Sythe Gold:
    0
    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?
     
  2. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    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 >


 
 
Adblock breaks this site