B&T's Tips & Scripts
How did you find this site?
  Search engine25 % 
  My webhost27 % 
  Another website29 % 
  Referral13 % 
  Other6 % 
The last vote was cast today
B&T's Tool Box
Password Generation
Length of Password
Include Numbers
Include Uppercase Letters
Include Lowercase Letters
Include Special Characters
Password Encryption for .htpasswd
Username
Password
Hex RGB Color Conversion
Hex #
RGB
Check HTTP status code
enter full url to be checked
Domain Name / IP Resolution
enter Domain Name or IP Address

B&T's Recommendations

Site5.com

Got (or getting) a Mac?

AppleChronicles.com

B&T's Tips & Scripts is a collection of Tips & Scripts to help you build a better website.  The Tips & Scripts are targeted towards the native Apache PHP MySQL environment.  Check back frequently as there will be additions and modifications.  Please check our terms of use.
B&T's Tips & Scripts is a safe website.
No pop-up ads and no evil downloads.
Search Tips & Scripts
as current the latest index of this site
Tag Definitions Date - most recent update
- for advanced users
- topic rating
php5 - requires php5 or later
Have you had enough programming and website building for a while?
Need a break to clear your mind?
Go to PrettyWorthless.com, where you will find nothing of value.


   Using .htaccess  

  1. .htaccess Basics Mar 9, 2006
  2. Domain & subdomain pointing May 12, 2005
  3. Automatic subdomains Jun 17, 2007
  4. Undefined subdomains Jul 20, 2008
  5. Prevent direct access to a pointer or subdomain directory Aug 15, 2006
  6. Forcing or eliminating the WWW. Feb 9, 2005
  7. Fixing the trailing slash problem May 11, 2005
  8. Friendly URLs Mar 21, 2007
  9. Rewrites and https Dec 18, 2007
  10. Blocking traffic to your website Jan 2, 2005
  11. Anti-leech May 25, 2005
  12. Fancy default index page Jan 25, 2005


   Using .htaccess/.htpasswd Password Protection  

  1. Setting up password protection Feb 9, 2005
  2. Encrypt your password for .htpasswd Dec 21, 2007
  3. Auto Password Change and Email Notification Dec 21, 2007 php5
  4. Auto generate .htpasswd file Dec 18, 2007 php5
  5. Passing user authentication information to PHP Jun 13, 2004


   Coding Tips  

  1. HTML "One Liners" Nov 13, 2005
  2. PHP "One Liners" Apr 5, 2007
  3. JavaScript "One Liners" Aug 25, 2007
  4. CSS examples Sep 9, 2006
  5. SQL coding examples Aug 29, 2006
  6. AJAX example Sep 24, 2006


   Uploads and Downloads  

  1. File Upload Script Dec 20, 2007 php5
  2. Custom Download Page Dec 14, 2007 php5
  3. Tracking and Securing Downloads Dec 20, 2007 php5


   Mail  

  1. Form Mail Aug 19, 2007
  2. Obfuscate your email address Nov 12, 2006
  3. Read and auto-process mail Nov 12, 2004
  4. Auto-responder Dec 18, 2007 php5
  5. Display your email message count Jul 30, 2004
  6. Setting up SPF Records Jan 4, 2007
  7. Specify a return-path for generated mail Jul 18, 2006


   Working with Images  

  1. Watermark images Jul 14, 2007
  2. Resize images (create thumbnails) Jul 14, 2007


   Frequently Requested Website Functionality  

  1. Visitor Counter Dec 14, 2007 php5
  2. 404 Error Page (with reporting and logging) Dec 20, 2007 php5
  3. CAPTCHA Aug 19, 2006
  4. Poll (voting) Dec 17, 2007 php5   see it on this page
  5. Weather Jul 27, 2008 php5
  6. FAQ Page May 23, 2005
  7. Random/weighted banners, quotes & more Feb 9, 2005
  8. Load a random image (simple) Jan 20, 2004
  9. Image (banner) rotation Oct 15, 2007
  10. Simple "members only" pages May 13, 2005
  11. Replace banned words Apr 5, 2007
  12. Get the most recent file date Jan 30, 2006
  13. Moving (bouncing) Image Nov 10, 2005
  14. Sticky default values for an input Oct 22, 2006


   Using PHP  

  1. Creating a custom php.ini file Dec 18, 2007 php5
  2. Copying the php.ini file Dec 18, 2007 php5
  3. Deleteing php.ini files Dec 18, 2007 php5
  4. Clean up your PHP scripts Nov 11, 2005
  5. Regular Expression Rules Mar 22, 2006


   Website Managment  

  1. Tips for keeping your website secure Jan 24, 2006
  2. Using Cron Sep 13, 2005
  3. Website Monitoring Dec 19, 2007
  4. Automated Site Backups Dec 19, 2007
  5. Automated MySQL Backups Dec 19, 2007
  6. Server-to-server file transfer December 16, 2006
  7. MySQL Error Notification Dec 20, 2007
  8. Find File and Directory Sizes Dec 14, 2007 php5
  9. Deleting session files Aug 9, 2006
  10. FTP made easy Mar 1, 2006
  11. Search and Replace Dec 14, 2007 php5


   Other Tips  

  1. URL Validation Feb 8, 2008
  2. Stop direct links to web pages Jan 22, 2004
  3. Ensure your page is not opened in a frame May 5, 2005
  4. Masking your URL in the Address Bar Jul 20, 2004
  5. Ban or allow IP Addresses (without using .htaccess) Jan 19, 20008
  6. Using Cookies Sep 24, 2006
  7. View your website in different resolutions Jan 2, 2005
 

Back to Top     Print this Tip

Auto-responder

This is an email auto-responder script.   The instructions for use are in the comments at the top of the script.   The script is intended to be run using Cron at preset invervals (for example every hour).   The script should be placed above the public directory to provide better security and to ensure no one else runs the script from http.

You can download this script as a .txt file.  Remember to rename the file as a .php file.

- - Start Script Here - -
<?php
/*
Email auto-responder script.  Save in a file named responder.php
The script reads an IMAP mail box and auto-responds to all emails where the to address matches an address in the addressMatch array.
All messages checked by the script are marked as read and the script will only respond to unread messages.  This prevents duplicate responses.
Optionally, can set a flag to only send one response per received email address.
  -> Controlled by entries in the responder.dat file, which the script will create for you.
  -> To reset to send everyone a response again, simply delete the responder.dat file.
You must review and change as needed all the variables in the section below.
*/

// This section contains the variables which are set to use the auto-responder script
$server "mail.yourdomain.com";
$user "XXXXXX";
$password "XXXXXX";
$subjectPrefix "Automatic Response to: ";  // response subject prefix - attaches to the front if the original subject
$addressMatch = array("address@yourdomain.com","address2@yourdomain.com");   // email address array of the to email addresses you want processed
$responseMessage "The auto-response message goes here";  // your auto-response message
$returnAddress "auto-responder@yourdomain.com";  // return address for the autoresponse - use an address NOT in $addressMatch or the script will not run
$returnLimit "N";  // must be Y to limit the auto-responses to one per email address
// End of user variables section - do not modify anything below this line unless you know what you are doing

$path "responder.dat";  // path to the file that contains addresses that have already received responses - used if $returnLimit = "Y"
if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i"$returnAddress))  die('Return address is not valid');
if (
in_array($returnAddress,$addressMatch)) die('Cannot use this email address as a return address'); 
$addressList "";
if (
file_exists($path)) $addressList file_get_contents($path);
$host "{".$server.":143"."}"."INBOX";
$msgStream imap_open($host$user$password);
$check imap_mailboxmsginfo($msgStream);
$number $check->Nmsgs;

function 
getheader($msgStream$msgNumber) {
  global 
$addressMatch;
  
$mailHeader imap_headerinfo($msgStream$msgNumber);
  
$headerArray = array();
  
$to $mailHeader->to;
  foreach (
$to as $id => $object) {
    
$test  $object->mailbox "@" $object->host;  // to address
    
if (in_array($test,$addressMatch)) { 
      
$headerArray[0] = "match";
      
$headerArray[1]  = $object->personal;  // to personal
      
$headerArray[2]  = $object->mailbox "@" $object->host;  // to address
    
}
  }
  
$from $mailHeader->from;
  foreach (
$from as $id => $object) {
    
$headerArray[3]  = $object->personal;  // from personal
    
$headerArray[4]  = $object->mailbox "@" $object->host;  // from address
  
}
  if (
$mailHeader->Unseen == 'U' || $mailHeader->Recent == 'N') { $headerArray[5] = "new"; } else { $headerArray[5] = "old"; }
  
$headerArray[6] = $mailHeader->subject;
  return 
$headerArray;
}


$msgNumber "1";
while (
$msgNumber <= $number) {
  
$headerArray getheader($msgStream$msgNumber);
  
$body=imap_body($msgStream,$msgNumber);
  if (
$headerArray[0] == "match") { 
    if ((
$returnLimit  !== "Y" OR ($returnLimit  == "Y"  AND substr_count($addressList,$headerArray[4]) == "0")) AND $headerArray[5] == "new" ) { 
      
$addressList .=  $addressList "|" $headerArray[4];
      
$subject $subjectPrefix $headerArray[6];
      
$headers "From: <$returnAddress>\n"
      
$headers .= "Reply-To: <$returnAddress>\n"
      
mail($headerArray[4],$subject,$responseMessage,$headers,"-f$returnAddress");
    }
  }
  
$msgNumber ++;
}
imap_close($msgStream);

if (
$returnLimit  == "Y"file_put_contents($path,$addressList);
?>

- - End Script Here - -

Rate This Topic



 
You are visitor 446,248
Last week there were 4,264 visitors
Copyright ©2004-2008