Discussion:
Running a script for email received
Ori Idan
2014-08-11 16:38:52 UTC
Permalink
I am trying to run a script when an email is received on my server.
I tried what described here:
http://blog.thecodingmachine.com/content/triggering-php-script-when-your-postfix-server-receives-mail

But it invoked the script for all mails not mail to a specific user
I tried the simplest thing of /etc/alias
But got error: Recipient address rejected: User unknown in virtual alias
table

Does anyone have any idea how to run a script for mail sent to a specific
user?
--
Ori Idan
Dolev Farhi
2014-08-11 19:09:29 UTC
Permalink
_______________________________________________
Linux-il mailing list
Linux-il-NSemkxREmS1YZAO8hgG6+***@public.gmane.org
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
E.S. Rosenberg
2014-08-12 09:47:06 UTC
Permalink
re:all
procmail and/or sieve seem to be the natural candidates....
With /etc/alias you could also pipe the mail into a script which would
trigger the script...
procmail and/or sieve seem to be the natural candidates....
With /etc/alias you could also pipe the mail into a script which would
trigger the script...
Post by Ori Idan
I am trying to run a script when an email is received on my server.
http://blog.thecodingmachine.com/content/triggering-php-script-when-your-postfix-server-receives-mail
But it invoked the script for all mails not mail to a specific user
I tried the simplest thing of /etc/alias
But got error: Recipient address rejected: User unknown in virtual alias
table
Does anyone have any idea how to run a script for mail sent to a specific
user?
--
Ori Idan
_______________________________________________
Linux-il mailing list
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Geoff Shang
2014-08-12 09:58:55 UTC
Permalink
Post by Ori Idan
I am trying to run a script when an email is received on my server.
http://blog.thecodingmachine.com/content/triggering-php-script-when-your-postfix-server-receives-mail
But it invoked the script for all mails not mail to a specific user
I tried the simplest thing of /etc/alias
But got error: Recipient address rejected: User unknown in virtual alias
table
/etc/aliases is used by the local delivery agent to deliver local mail.
That is to say, it delivers mail to actual accounts on the same system and
for addresses with domains listed in $mydestination. If the mailbox isn't
for an existing user or the domain is a virtual or relay domain, you will
need to use virtual_alias_maps.

The above suggests that postfix is looking in virtual_alias_maps for the
address to which you are sending. Unfortunately, scripts can't be used as
targets for virtual_alias_maps lookups.

You could alias a virtual address to a local address which is an alias for
the desired command. This is what Mailman does. For example, if you have
a mailing list called management for the domain example.com, Mailman's
virtual_alias_maps table would contain an entry like this:

management-***@public.gmane.org management

And Mailman's alias_maps file would contain:

management: "|/var/lib/mailman/mail/mailman post management"

Note that there isn't an actual user called management on the system.

This is probably the easiest way to achieve this, there are probably other
ways like setting up a transport which could be used to call the script as
described in the post but might not be worth the hassle for just one user.

All this is pretty well described in the various Postfix manpages. Feel
free to ask for further clarification, this stuff takes a bit to get one's
head around.

HTH,
Geoff.

Loading...