From: =?UTF-8?Q?Andr=C3=A9s_Gattinoni?= on
Hi there,

I've just suscribed because I'm having troubles to set up a postfix
server and just can't find the right answer in google.

I'm running Postfix 2.3.3 on a CentOS 5.4 box with Dovecot 1.0.7 for
authentication, Amavisd-new 2.6.4, SpamAssasin 3.3.1 and ClamAV 0.96.
I finally got it all working (I had never installed Amavisd-new
before, and that took me a while to figure out), but now I need
something more.

I need to set up some sort of hook that calls a PHP script for each
email received. I need something that can be applied globally to all
incoming emails (including the ones that are locally delivered) or at
least to all the addresses of a domain (because I won't be having too
many domains).

I've seen this link:
http://www.adkap.com/autoresponder.html

The problem there is that I don't know how to make that hook get
called for all my addresses (without having to add all of them to the
/etc/postfix/virtual_addresses file).

I've also seen this other link:
http://www.howtoforge.com/forums/showthread.php?t=38808

I created a transport file with something like this:
/.*@mydomain.com/ process-hook:

And then created this to the master.cf:

process-hook unix - n n - - pipe
flags=Fq user=nobody argv=/usr/bin/php /opt/mail_process.php
${sender} ${size} ${recipient}

But I think it's never being called.

Could you help me figure this out?

Thanks!

A

From: Noel Jones on
On 5/7/2010 2:53 PM, Andrés Gattinoni wrote:
> Hi there,
>
> I've just suscribed because I'm having troubles to set up a postfix
> server and just can't find the right answer in google.
>
> I'm running Postfix 2.3.3 on a CentOS 5.4 box with Dovecot 1.0.7 for
> authentication, Amavisd-new 2.6.4, SpamAssasin 3.3.1 and ClamAV 0.96.
> I finally got it all working (I had never installed Amavisd-new
> before, and that took me a while to figure out), but now I need
> something more.
>
> I need to set up some sort of hook that calls a PHP script for each
> email received. I need something that can be applied globally to all
> incoming emails (including the ones that are locally delivered) or at
> least to all the addresses of a domain (because I won't be having too
> many domains).

Here's an example of a shell script that receives all mail.
Shouldn't be much of a stretch to use PHP instead.
http://www.postfix.org/FILTER_README.html#simple_filter

If you still want to use amavisd-new, then use multiple
postfix instances for each filter hop.

Another alternative is to integrate your code into
amavisd-new, either as a custom hook or as a pseudo antivirus
scanner. Check the amavis-users archives for other folks
doing similar things.


-- Noel Jones

From: =?UTF-8?Q?Andr=C3=A9s_Gattinoni?= on
On Fri, May 7, 2010 at 5:29 PM, Noel Jones <njones(a)megan.vbhcs.org> wrote:
> On 5/7/2010 2:53 PM, Andrés Gattinoni wrote:
>>
> Here's an example of a shell script that receives all mail. Shouldn't be
> much of a stretch to use PHP instead.
> http://www.postfix.org/FILTER_README.html#simple_filter
>
> If you still want to use amavisd-new, then use multiple postfix instances
> for each filter hop.
>
> Another alternative is to integrate your code into amavisd-new, either as a
> custom hook or as a pseudo antivirus scanner.  Check the amavis-users
> archives for other folks doing similar things.

Thanks for your response Noel.
I've checked out that link. The thing is that I don't actually to do
any filtering inside my script, I just need to gather some
information.
Maybe there's an easier way that I can do that without having to call
sendmail again.

Could you tell me more about how to use multiple postfix instances to
keep using amavisd-new?
This is what I added to my master.cf to make amavisd-new work. What
would I need to add?

#the amavis connector, to send to amavis
amaviasd-new unix - - - - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
#The amavis receiver
127.0.0.1:10026 inet n - y - - smtpd
-o content_filter=

#Stop Postfix from cleaning emails before sending to amavis
pre-cleanup unix n - y - 0 cleanup
-o virtual_alias_maps=
-o canonical_maps=
-o sender_canonical_maps=
-o recipient_canonical_maps=
-o masquerade_domains=

#Regular messsages can get cleaned up
cleanup unix n - y - 0 cleanup
-o mime_header_checks=
-o nested_header_checks=
-o body_checks=
-o header_checks=

smtp inet n - n - - smtpd
-o cleanup_service_name=pre-cleanup

submission inet n - n - - smtpd
-o cleanup_service_name=pre-cleanup

pickup fifo n - y 60 1 pickup
-o cleanup_service_name=pre-cleanup

I would checkout the idea of the hook for amavisd-new. Maybe if it's
not to messy it could be a good solution.

Regards,

A

From: Noel Jones on
On 5/7/2010 3:40 PM, Andrés Gattinoni wrote:
> On Fri, May 7, 2010 at 5:29 PM, Noel Jones<njones(a)megan.vbhcs.org> wrote:
>> On 5/7/2010 2:53 PM, Andrés Gattinoni wrote:
>>>
>> Here's an example of a shell script that receives all mail. Shouldn't be
>> much of a stretch to use PHP instead.
>> http://www.postfix.org/FILTER_README.html#simple_filter
>>
>> If you still want to use amavisd-new, then use multiple postfix instances
>> for each filter hop.
>>
>> Another alternative is to integrate your code into amavisd-new, either as a
>> custom hook or as a pseudo antivirus scanner. Check the amavis-users
>> archives for other folks doing similar things.
>
> Thanks for your response Noel.
> I've checked out that link. The thing is that I don't actually to do
> any filtering inside my script, I just need to gather some
> information.
> Maybe there's an easier way that I can do that without having to call
> sendmail again.
>
> Could you tell me more about how to use multiple postfix instances to
> keep using amavisd-new?

sort of like this:

input->postfix1->amavis->postfix2->php->postfix3->delivery

http://www.postfix.org/MULTI_INSTANCE_README.html
You'll have to work out the details yourself.

> I would checkout the idea of the hook for amavisd-new. Maybe if it's
> not to messy it could be a good solution.

Doing this in amavisd-new may work out easier if your script
just needs to see the mail and not alter the mail or delivery.
Sounds conceptually like a command-line virus scanner, and
maybe easiest to integrate it that way.


-- Noel Jones

From: mouss on
Andrés Gattinoni a écrit :
> On Fri, May 7, 2010 at 5:29 PM, Noel Jones <njones(a)megan.vbhcs.org> wrote:
>> On 5/7/2010 2:53 PM, Andrés Gattinoni wrote:
>> Here's an example of a shell script that receives all mail. Shouldn't be
>> much of a stretch to use PHP instead.
>> http://www.postfix.org/FILTER_README.html#simple_filter
>>
>> If you still want to use amavisd-new, then use multiple postfix instances
>> for each filter hop.
>>
>> Another alternative is to integrate your code into amavisd-new, either as a
>> custom hook or as a pseudo antivirus scanner. Check the amavis-users
>> archives for other folks doing similar things.
>
> Thanks for your response Noel.
> I've checked out that link. The thing is that I don't actually to do
> any filtering inside my script, I just need to gather some
> information.

What kind of information? if it's just about envelope, then logs are
enough.

> Maybe there's an easier way that I can do that without having to call
> sendmail again.
>
> [snip]