PHPBuilder - How to build a mailbot in PHP Page 4



RSS Twitter
Articles Php Functions

How to build a mailbot in PHP - Page 4

by: Michael Galloway
|
November 6, 2002

You may also want to do additional regular expression checks to insure the "Reply-To" address is a valid email. A simple way to do that (no doubt great improvements could be made), is to do the following:

<?php
if(ereg("^.+@.+\..+$",$message_head["reply-to"])) 
$valid_reply_to true;
else  
$valid_reply_to false;
?>
Now we do our decision-making "if" statement. Basically the technique I use to avoid the message loops (which, by the way, can crash a server in no time) is to require the word "unsubscribe" in the subject header. If, for some reason, the message the mailbot sends is returned, the subject will be changed (it would now say something like "Returned Mail"), and the mailbot will not reply. Thus a loop is avoided.

<?php
if(eregi("unsubscribe",$message_head[subject]) && $valid_reply_to) {

$message "Dear $message_head[from]\n\nWe have unsubscribed you.";

mail($message_head["reply-to"],
             
"Mailbot",
             
$message,
             
"From: mailbot@neoterra.com");

?>
Finally we should close the pointer to the $stdin file. (You don't need to do this in 4.3)

<?php
fclose
($stdin);
?>
So now we have the mailbot software ready to go. You may consider having it dump information into a logfile for error checking purposes, since you will not be running this from the command line.

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Michael Galloway

Comment:



Comment:

(Maximum characters: 1200). You have characters left.