autoresponder for all accounts

asmithjr

Well-Known Member
Jun 13, 2003
516
8
168
Anyone know of a way to put an autoresponder for all accounts in the office,

For example: when an office is closed for a holiday

Another question, Any way to set up a cron or schedule the auto response to start at a certain time.
 
  • Like
Reactions: mlopez

asmithjr

Well-Known Member
Jun 13, 2003
516
8
168
well I decided to just write one to fit my needs, Crude but it works
Code:
<?php
    // AUTORESPONDER WRITE TO .autorespond folder email file
    /*
    From: "[email protected]" <[email protected]>
    Content-type: text/plain; charset=utf-8
    Subject: test autoresponse
     
    BODY HERE
    */
     
    $domain = $_SERVER['HTTP_HOST'];
    $mydomain = explode("www.", $domain);
    $mydomain = $mydomain[1];
    global $HTTP_GET_VARS, $HTTP_POST_VARS;
     
    $Host = explode("/", $_SERVER['DOCUMENT_ROOT']); // path info
    $HOST = "/".$Host[1]."/".$Host[2];
    $file = $HOST."/etc/".$mydomain."/passwd";
    $dir = $HOST."/.autorespond";
     
    // write a file for each email for the domain
    // Display a List of the current emails
    $fp = fopen($file, "r"); // are we in the right folder
    if (!is_resource($fp)) {
        //echo "HI";
        return -1;
    }
    while (!feof($fp)) {
        $line = fgets($fp);
        $fields = explode(":", $line);
        if ($fields[0]) {
            // do the writing of the file to the $dir
            //echo $fields[0]."@".$mydomain."<br>";
            $email = $fields[0]."@".$mydomain;
            $display .= "<option>$email</option>";
        } // end fields
    } // end while
    $emails = $_POST['emails'];
    $subject = $_POST['subject'];
    $Body = $_POST['Body'];
    $AddDelete = $_POST['add_or_delete'];
    $Autoresponder = $_POST['autoresponder'];
     
    $efile = $dir."/".$email;
     
    // if they entered a subject then write the autoresponder
    if ($Autoresponder) {
        // write a file for each email for the domain
        // Display a List of the current emails
        foreach ($emails as $email) {
            //echo $email;
            $efile = $dir."/".$email;
            $contents = "From: \"$email\" <$email>\n";
            $contents .= "Content-type: text/plain; charset=utf-8\n";
            $contents .= "Subject: $subject\n\n";
            $contents .= "$Body\n";
            if ($AddDelete === "Add") {
	if (($subject) && ($Body)) {
                $fe = fopen($efile, "w"); // are we in the right folder
                 
                // Write $somecontent to our opened file.
                if (fwrite($fe, $contents) === FALSE) {
                    echo "Cannot write to file ($efile)<br>";
                    exit;
                } else {
                    $msg .= "Updated autoresponder for <b>$email</b><br>";
                }
                fclose($fe);
	} else {
		$msg = "<font color=red>Please check Email(s) Subject and Body..";
        }
            } else {
                $msg .= "Deleted <b> $efile </b><br />";
                unlink($efile);
            }
        } // end foreach
    }
?>

<html>
<head>
</head>
<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="
0" summary="login form">
          <tr>
            <td width="750" valign="top"><fieldset class="login" id="login" title=
"Login">
<fieldset>
              <legend>Autoresponder Admin</legend>
<form name="autorespond" method="POST" action="">
<input type="hidden" name="autoresponder" value="Yes">
<table border=0 align=center width=90%>
<tr><td>Select email(s): (Hold CTRL key to select multiple)<br />
<select multiple name=emails[] size=10>
<? echo $display; ?>
<select>
</td>
</tr>
<tr>
<td>Subject:<br /><input size="55" type="text" name="subject"> </td>
</tr>
<tr>
<td>Body:<br /><textarea rows="8" cols="75" name="Body"></textarea> </td>
</tr>
</table>
Add Selected: <input type="radio" checked value="Add" name="add_or_delete">
Delete Selected: <input type="radio" value="Delete" name="add_or_delete">
<input type="submit" value="Update Auto Responder(s)">
</form>
<? echo $msg; ?>
</fieldset>

</body>
</html>
This will not work if you cannot ready you own passwd file!