Dripping with Talent Administration
2004-02-20 20:14:51 UTC
Hi,
I'm new to the list and rather new to postfix as well. Any help here
would be great. I spent a while trying to find an autoresponder to add into
our postfix / cyrus / mysql / amavisd-new + clamav + spamassassin / courier
- etc, another modularized cocktail. Anyways, I've written a php module for
Squirrelmail to allow customers to create or remove their autoresponders and
forwarding addresses (just queries a mysql database and retrieves the
autorespond info or writes it). Then, for the postfix side, we've written a
short module that says if autoresponder=yes, create a mail with
autoRespondSubject and autoRespondBody and send it to the $fromaddress
that's passed from postfix... code is below:
We have this entry in master.cf:
autoreply unix - n n - - pipe
user=postfix argv=/etc/postfix/pipe.php ${sender} ${recipient}
and specific test accounts are routed directly to it in transport.map. And
it works - to some degree. The auto-response is generated and sent, however,
the original email disappears - isn't rejected, isn't put back into a queue
and most unfortunately, never delievered to the original recipient. Any
ideas on how we can tell master.cf to just use the autoresponder and not
actually give it the message, or maybe something we can add to our program
to force the message back into a queue?
Thanks,
Damien Kemens,
-Eq_dev-
#!/usr/bin/php -q
<?php
$failed1 = "Failed with exit status 1";
$failed2 = "Failed with exit status 2";
$fromaddress = $argv[1];
$toaddress = $argv[2];
mysql_connect("localhost", "[username omitted]", "[password omitted]");
mysql_select_db("postfix");
$username = explode("@", $toaddress);
if(!eregi($username[1], "ly.net") && $dogs == "pie") {
fwrite($fp, $failed1);
exit;
} else {
$customer = $username[0];
$customer = trim($customer);
$query1 = mysql_query("SELECT AutoRespond from users WHERE
username='$customer'");
$result1 = mysql_fetch_array($query1);
$autostatus = $result1['AutoRespond'];
if($autostatus != "1") {
fwrite($fp, $failed2);
exit;
}
$query2 = mysql_query("SELECT AutoRespondSubject from users WHERE
username='$customer'");
$result2 = mysql_fetch_array($query2);
$subject = $result2['AutoRespondSubject'];
$query3 = mysql_query("SELECT AutoRespondText from users WHERE
username='$customer'");
$result3 = mysql_fetch_array($query3);
$body = $result3['AutoRespondText'];
$headers = "From: $toaddress <$toaddress>";
$headers .= "To: $fromaddress <$fromaddress>";
mail($fromaddress, $subject, $body, $headers);
$fp = fopen("counter.txt", "a");
fwrite($fp, $stuff);
fclose($fp);
}
?>
I'm new to the list and rather new to postfix as well. Any help here
would be great. I spent a while trying to find an autoresponder to add into
our postfix / cyrus / mysql / amavisd-new + clamav + spamassassin / courier
- etc, another modularized cocktail. Anyways, I've written a php module for
Squirrelmail to allow customers to create or remove their autoresponders and
forwarding addresses (just queries a mysql database and retrieves the
autorespond info or writes it). Then, for the postfix side, we've written a
short module that says if autoresponder=yes, create a mail with
autoRespondSubject and autoRespondBody and send it to the $fromaddress
that's passed from postfix... code is below:
We have this entry in master.cf:
autoreply unix - n n - - pipe
user=postfix argv=/etc/postfix/pipe.php ${sender} ${recipient}
and specific test accounts are routed directly to it in transport.map. And
it works - to some degree. The auto-response is generated and sent, however,
the original email disappears - isn't rejected, isn't put back into a queue
and most unfortunately, never delievered to the original recipient. Any
ideas on how we can tell master.cf to just use the autoresponder and not
actually give it the message, or maybe something we can add to our program
to force the message back into a queue?
Thanks,
Damien Kemens,
-Eq_dev-
#!/usr/bin/php -q
<?php
$failed1 = "Failed with exit status 1";
$failed2 = "Failed with exit status 2";
$fromaddress = $argv[1];
$toaddress = $argv[2];
mysql_connect("localhost", "[username omitted]", "[password omitted]");
mysql_select_db("postfix");
$username = explode("@", $toaddress);
if(!eregi($username[1], "ly.net") && $dogs == "pie") {
fwrite($fp, $failed1);
exit;
} else {
$customer = $username[0];
$customer = trim($customer);
$query1 = mysql_query("SELECT AutoRespond from users WHERE
username='$customer'");
$result1 = mysql_fetch_array($query1);
$autostatus = $result1['AutoRespond'];
if($autostatus != "1") {
fwrite($fp, $failed2);
exit;
}
$query2 = mysql_query("SELECT AutoRespondSubject from users WHERE
username='$customer'");
$result2 = mysql_fetch_array($query2);
$subject = $result2['AutoRespondSubject'];
$query3 = mysql_query("SELECT AutoRespondText from users WHERE
username='$customer'");
$result3 = mysql_fetch_array($query3);
$body = $result3['AutoRespondText'];
$headers = "From: $toaddress <$toaddress>";
$headers .= "To: $fromaddress <$fromaddress>";
mail($fromaddress, $subject, $body, $headers);
$fp = fopen("counter.txt", "a");
fwrite($fp, $stuff);
fclose($fp);
}
?>