This class implements an email auto-response system. It accesses mailboxes via POP3 or IMAP protocols and sends out automatic responses emails to the messages found in the inbox folder.
Currently it implements three types of auto-response:
The response messages may be in plain text or HTML. After the auto-response is sent, the mails are marked read or can be deleted.This class is meant to be used from tasks run periodically for instance as cron jobs. Also it is possible to use this class from a webpage.
Functions implemented:
Send out a simple custom autoresponder:
/* include the main class */
include("autoresponse.class.php");
/* create a object of the class */
$respond=new autoresponse('vedanta@exampledomain.com','bulky','vedanta@exampledomain.com','mail.exampledomain.com');
/* connect to the mail server specified in the constructor */
$respond->connect();
/* set a autoresponse content */
$respond->responseContentSource="This is a response to your mail!";
/* send out a html format custom autoresponse and delete all the mails in the mail server */
$respond->send('custom','html',true);
/* close the mailbox */
$respond->close_mailbox();
Send out a file autoresponse in html format:
/* include the main class */
include("autoresponse.class.php");
/* create a object of the class */
$respond=new autoresponse('vedanta@exampledomain.com','bulky','vedanta@exampledomain.com','mail.exampledomain.com');
/* connect to the mail server specified in the constructor */
$respond->connect();
/* set a autoresponse content to a file in the system*/
$respond->responseContentSource="/path/to/a/readable/file/in/your/system";
/* send out a html format file autoresponse and do not delete the mails in the mail server */
$respond->send('custom','html');
/* close the mailbox */
$respond->close_mailbox();
Send out a url autoresponder:
In this type of autoresponder the url request is made by a valid url on the subject line:
E.g: Here are the headers of one such mail:
X-Booh-Received: 8d8347bcf82058be591c38be5468824261263390
Received: by 10.54.43.42 with HTTP; Mon, 6 Dec 2004 08:00:42 -0800 (PST)
Message-ID: <c52b4e4c04120608001c9dc0af@mail.booh.com> Date: Mon, 6 Dec 2004 21:30:42 +0530 From: Vedanta Barooah <vedanta.barooah@booh.com>
Reply-To: Vedanta Barooah <vedanta.barooah@booh.com>
To: give_me_the_url@something.com
Subject: http://www.gnu.org
Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit
Delivered-To: vedanta.barooah@booh.com
Notice the subject line requesting the URL, so the code will be as follows:
$respond=new autoresponse('vedanta@exampledomain.com','elephant','vedanta@exampledomain.com','mail.exampledomain.com');
$respond->connect();
$respond->send('url','html');
$respond->close_mailbox();
Please post me bugs and feature requests at : vedanta.barooah at gmail dot com
;-)