Location: PHPKode > scripts > Auto-Responder > auto-responder/manual.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Auto-Responder Manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.coderef{
	border:thin solid #606060;
	padding:6px;
	font-family:"Courier New", Courier, mono;
	font-size:small;
	background-color:#fefefe;
}
.code{
	border:thin solid #606060;
	padding:6px;
	font-family:"Courier New", Courier, mono;
	font-size:x-small;
	background-color:#f0f0f0;
}

</style>
</head>
<body>
<h1>Auto-Responder (autoresponse.class.php)</h1>
<p>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. </p>
<p>Currently it implements three types of auto-response: </p>
<ul>
  <li>Send a response message using a given file </li>
  <li> Send response message using contents read from a given Web URL (in this case the email subject has the URL request) </li>
  <li> Send a custom response message generated by the current script </li>
</ul>
<p>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. </p>
<p><strong>Functions implemented: </strong></p>
<div  class="coderef">
<strong>autoresponse($username,$password,$responderEmail,$mailserver='localhost',$servertype='pop',$port='110')</strong><br>
    <strong>Class
Constructor:</strong><br> 
<strong>$username</strong>: Mail User Name ( for some servers, like name based hosts you might need to write the complete email address with the domain name. E.g: hide@address.com)<br>
<strong>$password</strong>: Mail User's Password <br>
<strong>$respondersEmail: </strong>This email appears in the from field of the auto-response.<br>
<strong>$mailserver: </strong>Mail Server to connect to, (Optional if you are running the script on the same server)<br>
<strong>$servertype</strong>: Type of mail server i.e pop or imap, (Optional paramater if you are using a pop3 mail server)<br>
<strong>$port</strong>: Port in which the mail server accepts connections, (143 for imap, Optional if you use pop in the $servertype arg) </div>
<br>
<div class="coderef"><strong> void connect(void)</strong>:
  Connects to the mail server
</div>
<br>

<div class="coderef">
<strong>$responseContentSource="$string_source"</strong>: Source to pick up the mail content from, in case of a custom and file autoresponder, thoug its absurd in case of a url autoresponder.<br>
<br>
In case of a file auto responder the path of the file is given as: <br>
$o-&gt;responseContentSource="/path/to/readable/file"; <br>
<br>
In case of a custom autoresponder it is as: 


<br>
$respond-&gt;responseContentSource="This is a response to your mail!";<br> 
or<br>
$respond-&gt;responseContentSource="$message&quot;; # $message contains the autoresponse message </div>
<br>
<div class="coderef"><strong> void send($type='custom',$format='html',$deleteMails=false):</strong>Send out the autoresponder message<br>
  <strong>$type</strong>: Type of auto responder message, valid types are custom, file or url (Optional if type is custom) <br>
  <strong>$format: </strong>Format of the mail that is sent out, valid formats are html or text (Optional if format is html)<br>
<strong>$deleteMails: </strong>Valid args are true or false, Does the script delete the mails after the autoresponder is sent out.</div>
<br>
<div class="coderef">
<strong>void close_mailbox(void)</strong>:Close the mailbox after the auto responder is sent out </div>
<br>
<br>
<strong>Examples:<br>
<br>
<p class="code">
Send out a simple custom autoresponder:
  <br>
/* include the main class */<br>
include(&quot;autoresponse.class.php&quot;);<br>
  /* create a object of the class */ <br>
  $respond=new autoresponse('hide@address.com','bulky','hide@address.com','mail.exampledomain.com'); <br>
  /* connect to the mail server specified in the constructor */ <br>
  $respond-&gt;connect();<br>
/* set a autoresponse content */<br>
$respond-&gt;responseContentSource="This is a response to your mail!";<br>
/* send out a html format custom autoresponse and delete all the mails in the mail server */ <br>
$respond-&gt;send('custom','html',true); <br>
/* close the mailbox */ <br>
$respond-&gt;close_mailbox();</p>
<p class="code">Send out a file autoresponse in html format:<br>
  /* include the main class */<br>
  include(&quot;autoresponse.class.php&quot;);<br>
  /* create a object of the class */ <br>
  $respond=new autoresponse('hide@address.com','bulky','hide@address.com','mail.exampledomain.com'); <br>
  /* connect to the mail server specified in the constructor */ <br>
  $respond-&gt;connect();<br>
  /* set a autoresponse content to a file in the system*/<br>
  $respond-&gt;responseContentSource=&quot;/path/to/a/readable/file/in/your/system&quot;;<br>
  /* send out a html format file autoresponse and do not delete the mails in the mail server */ <br>
  $respond-&gt;send('custom','html'); <br>
  /* close the mailbox */ <br>
$respond-&gt;close_mailbox();</p>
<p class="code">Send out a url autoresponder:<br>
  In this type of autoresponder the url request is made by a valid url on the subject line:<br>
  E.g: Here are the headers of one such mail:<br>
  <br>
  X-Booh-Received: 8d8347bcf82058be591c38be5468824261263390 <br>
Received: by 10.54.43.42 with HTTP; Mon, 6 Dec 2004 08:00:42 -0800 (PST)<br> 
Message-ID: &lt;hide@address.com&gt; Date: Mon, 6 Dec 2004 21:30:42 +0530 From: Vedanta Barooah &lt;hide@address.com&gt; <br>
Reply-To: Vedanta Barooah &lt;hide@address.com&gt; <br>
To: hide@address.com <br>
Subject: http://www.gnu.org <br>
Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit <br>
Delivered-To: hide@address.com<br>
<br>
Notice the subject line requesting the URL, so the code will be as follows:<br>
<br>
$respond=new autoresponse('hide@address.com','elephant','hide@address.com','mail.exampledomain.com');<br>
$respond-&gt;connect();<br>
$respond-&gt;send('url','html');<br>
$respond-&gt;close_mailbox();</p>
<p>Please post me bugs and feature requests at : vedanta.barooah at gmail dot com</p>
<p>;-)</p>
<br>
</strong><br>

<br>
<br>
<br>
<p>&nbsp;</p>
<p><br>
</p>
</body>
</html>

Return current item: Auto-Responder