Hi guys
Here's the scenario...
I'd like to intercept all unrouted mail and scan the contents for key phrases. If found then send a specific response, if not then send a standard response.
Here's what I have thus far:
Now it works, kind of. It sends 25 messages so I can only assume it's sending one message for each line of the file it opens.PHP Code:#! usr/local/bin/php -q
<?php
// Read From Stdin:
$data = '';
$file = fopen('php://stdin', 'r');
while(!feof($file))
{
$data .= fgets($file, 4096);
// Let's Do Something:
$to = "Me@MyWebsite.com";
$subject = "Test Mail From PHP Mail Interceptor";
$message = "Hello! This is a simple email message from your mail interceptor.";
$from = "MailInterceptor@MyWebsite.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
}
fclose($file);
?>
Here's what I would "like" to do...
I tried and inserted an if statement following stristr but the mail failed.PHP Code:#! usr/local/bin/php -q
<?php
// Read From Stdin:
$data = '';
$file = fopen('php://stdin', 'r');
while(!feof($file))
{
// Define a string to look for here. "Chicken Wings Special" for example
// Search here for "$SearchString" using stristr perhaps...?
// Now run an if statement and send a mail "IF" $SearchString is found
$data .= fgets($file, 4096);
// Let's Do Something:
$to = "Me@MyWebsite.com"; <-- Inject the sender's mail address here
$subject = "Test Mail From PHP Mail Interceptor"; <-- This I can customise based on the $SearchString
$message = "Hello! This is a simple email message from your mail interceptor.";
$from = "MailInterceptor@MyWebsite.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
}
fclose($file);
?>
Any suggestions...?


Reply With Quote
Bookmarks