Full-Service Internet Marketing & Web Development | WebMail
Call us Toll-Free:
1-800-218-1525
Email us

Business Automation - Meet your Employee of the Month

Mike Peters, 07-25-2007
If you don't understand why Business Automation is so important, go read The E-Myth first, then come back to this post.

--

Ok, great. So you know why Business Automation can make or break your business.

Are you finding yourself constantly sending repetitive emails to your key employees?

Here are some examples of what I mean -

* "Chris, we need to refund yesterday's order by Roger Frankel. He changed his mind"
* "Jane, please login to ClickBank and send me a list of the top 5 products right now"
* "Ben, how did we do with sales yesterday compared to last week?"
* "Kim, what's the situation with the customer support back log?"

Sounds familiar?

What if you had a single employee you could always email questions and instructions to and get stuff done right away, 24 hours a day?

Meet your new Employee of the Month -- sendmail script automation.

How does it work?

You send an email to robot@yourdomain.com, asking any one of a predefined sets of questions or instructions. Anything like "send sales summary", "refund mike@softwareprojects.com" or "suspend ppc campaigns".

Your robot understands the instruction, executes it right away and emails you back a summary of what was done.

This is very simple to implement and could help you cut cost, save time and streamline your business.

How to Implement

The first thing we have to do is tell our email system to send all emails to robot@yourdomain.com to our script.

Open up your email virtusertable (typically under /etc/virtusertable) and define this alias:

robot: "|/home/robot.php"
Replace /home/robot.php with the full path where you're going to place the robot script.

Now go to the directory where you'd like robot.php to run, open up a new file named robot.php and paste this code:


<?php #!/usr/bin/php
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!
feof($fd)) {
 
$email .= fread($fd, 4096);
}
fclose($fd);

// handle email
$lines = explode("n", $email);

// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;

for (
$i=0; $i < count($lines); $i++) {
  if (
$splittingheaders) {
  
// this is a header
  
$headers .= $lines[$i]."n";

  
// look out for special headers
  
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
   
$subject = $matches[1];
   }
   if (
preg_match("/^From: (.*)/", $lines[$i], $matches)) {
   
$from = $matches[1];
   }
  } else {
  
// not a header, but message
  
$message .= $lines[$i]."n";
  }

  if (
trim($lines[$i])=="") {
  
// empty line, header section has ended
  
$splittingheaders = false;
  }
}
?>

We now have a script that will get executed whenever sending an email to robot@yourdomain.com. The script will parse all headers of the email message, storing the subject of the message (where you will be giving the robot script instructions) into a local variable.

Now all you have to do is write handler functions to handle every single one of your frequent questions.

In an effort of keeping this article short, here's how you would add handling for a "what time is it" question:


<?php if (Strcasecmp($subject,"what time is it")==0)
{
$answer = strftime("It is now %H:%M, %d-%m-%Y");
}

// Email response back
if (!empty($answer))
{
mail($from, "RE: $subject", $answer, "From: ");
}
?>

In Summary

Business Automation is a very powerful tool.

Ask your engineer to implement an email robot and teach it how to address the most frequent questions and instructions.

Please use the comments section to let me know which other common tasks you find yourself handling in your business, or contact me directly if you'd like the code.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.


About us  |  Contact us  |  Privacy  |  Terms & Conditions  |  Affiliates

© 2008 Software Projects Inc. (SPI)
Thursday, August 21st, 2008
Page generated in 0.344 seconds