• Log in or sign up for an account here: https://www.sythe.org/login

Using the PHP imap() function

denny8569

Newcomer
Joined
Feb 12, 2010
Sythe Gold
0
Messages
3
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?
 
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.
 
Back
Top