Discussion:
Autoresponder and master.cf
(too old to reply)
Dripping with Talent Administration
2004-02-20 20:14:51 UTC
Permalink
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);
}
?>
V***@morganstanley.com
2004-02-20 20:25:17 UTC
Permalink
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?
Instead of delivering mail for target recipients to the autoresponder,
rewrite the recipients to two addresses and deliver the second address to
the autoresponder:

***@example.com ***@example.com, test%***@autoresp.invalid

Add a transport table entry for autoresp.invalid to use your
autoresponder pipe command.
--
Viktor.
Richard Bewley
2004-02-20 21:00:41 UTC
Permalink
Hello,

If we were to do it this way, what would be the best way of going about
adding in the second recipient, say ***@ourdomain.com? I know we
could always use the always_bcc option, but this seems messy, is there a way
to copy the message from master?

Thank you,
Richard Bewley

-----Original Message-----
From: owner-postfix-***@postfix.org
[mailto:owner-postfix-***@postfix.org] On Behalf Of
***@morganstanley.com
Sent: Friday, February 20, 2004 3:26 PM
To: Postfix Users List
Subject: Re: Autoresponder and master.cf
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?
Instead of delivering mail for target recipients to the autoresponder,
rewrite the recipients to two addresses and deliver the second address to
the autoresponder:

***@example.com ***@example.com, test%***@autoresp.invalid

Add a transport table entry for autoresp.invalid to use your
autoresponder pipe command.
--
Viktor.
Dripping with Talent Administration
2004-02-21 04:26:42 UTC
Permalink
Thanks guys, we've figured it out ourselves - no need banging your head
against the wall trying to help us.

Forward address -> ***@autorply.domain.com which via transport pipes to our
autoreply software - the software handles the rest.

-----Original Message-----
From: owner-postfix-***@postfix.org
[mailto:owner-postfix-***@postfix.org] On Behalf Of
***@morganstanley.com
Sent: Friday, February 20, 2004 3:26 PM
To: Postfix Users List
Subject: Re: Autoresponder and master.cf
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?
Instead of delivering mail for target recipients to the autoresponder,
rewrite the recipients to two addresses and deliver the second address to
the autoresponder:

***@example.com ***@example.com, test%***@autoresp.invalid

Add a transport table entry for autoresp.invalid to use your
autoresponder pipe command.
--
Viktor.
Loading...