PDA

View Full Version : Need help with Cronjobs



BLiZZaRD
09-15-2005, 05:34 PM
I am trying to set up an automatic email response form. I don't know what I am doing though, and after following the rules of what I have found here is where I am:

I get a cron report every 15 minutes, but it is empty, and the emails DON'T get the auto-response.

here it the cron code:

RCPT="mail -s Cron_Results bigblizz@gmail.com"
*/15 * * * * /www/u/myuser/etc/responder.php|$RCPT


and here is my responder.php:

<?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 = "http://webmail.cleverwasteoftime.com";
$user = "XXXXXXX";
$password = "XXXXXXXX";
$subjectPrefix = "Automatic Response to:"; // response subject prefix - attaches to the front if the original subject
$addressMatch = array("quest.htm@cleverwasteoftime.com"); // email address array of the to email addresses you want processed
$responseMessage = "Hello, and thank you for your email.


Yes it is true we now have everything we need to block you from playing the

game. We sure do hate cheating. HOWEVER, we have had this information
since you entered the "l" to the .htm way back in level 3.

Do not stress, we do not spam, we do not sell, and we do not parade any
information around. It is a security device we install to ensure a pure
gaming experience for all involved.

This level is here to help deter those that think they can out smart us.
If the information contained in the email does not match up directly with
the solvable methods for reaching this far in the game, we will begin
blocking you around levels 37 to 40.

This is why you were able to move on to level 36. (If you pay attention)

Another assumption we are going to make is that this email stays between
you and us. If we find this email, or any information herein, posted or
publicly discussed in any way or form, we will block you and all others
that come from where the information is broadcast.

YOU ARE cleared to continue the game. Good luck with the rest and
HAVE FUN!

-Team CWoT"; // your auto-response message
$returnAddress = "bigblizz@cleverwasteoftime.com"; // return address for the autoresponse - use an address NOT in $addressMatch or the script will not run
$returnLimit = "Y"; // 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") {
$filePointer = fopen($path, "w" );
fwrite($filePointer, $addressList);
fclose($filePointer);
}
?>


I have left the "//instructions" tags in. Any help???