5

Possible Duplicate:
How to configure postfix to pipe all incoming email to a script?

I'm having problems setting up simple piping for Redmine (or '|cat > /tmp/temp')

/etc/postfix/virtual:

support@myhost.com support

/etc/postfix/aliases:

support: "|/opt/redmine-1.2.2/processemail.sh"

main.cf

virtual_alias_maps = hash:/etc/postfix/virtual, mysql:/etc/postfix/mysql_virtual_forwards.cf
virtual_mailbox_domains = myhost.com, mysql:/etc/postfix/mysql_virtual_domains.cf
virtual_mailbox_maps = hash:/etc/postfix/virtual_alias, mysql:/etc/postfix/mysql_virtual_mailboxes.cf

alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps

processemail.sh:

#!/bin/sh
/opt/redmine-1.2.2/extra/mail_handler/rdm-mailhandler.rb --url http://myhost.com --key f5obfctmGfqZWnOWNtR8 --project test --tracker support --allow-override tracker,project --verbose --unknown-user accept --no-permission-check

I've run newaliases; postmap virtual; postalias aliases; postalias virtual_alias; newalias - Yeah, probably overdoes it, but still misses the pouint :(

I've run newaliases and restarted postfix. Mail is delivered as usual, but nothing is added to /tmp

This is the only log entry saying anything about virtual.

Dec 10 04:08:41 master postfix/virtual[3112]:
A3F46AD1BF: to=<support@myhost.com>, relay=virtual, delay=0.4,
delays=0.38/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)

If I run cat someemail | processemail.sh in the shell, everything works. Processemail isn't even run by postfix.

Anyone knows what might be wrong? Or how I can turn on more logging?

simendsjo
  • 189
  • 1
  • 9
  • Yes, an exact duplicate. I just found a solution and was posting it the same second the question was closed :) Would have saved a couple of hours if I found that answer first. – simendsjo Dec 11 '11 at 15:11

2 Answers2

6

Pipe Alias are implemented by local(8) postfix agent.

relay=virtual

This means you are using the virtual(8) agent delivery to support@myhost.com but you need local(8) to fetch that email. Maybe you using virtual as your local_transport or you need to put in your 'virtual_alias_maps' file something like:

support@myhost.com support@localhost

This postfix-users thread and the postfix documentation may help.

scyldinga
  • 178
  • 1
  • 6
1

You could use a simple alias in /etc/aliases (or wherever it is located):

support: |/usr/local/bin/yourscripthandler

Don't forget to run newaliases afterwards.

Note that redirection (>/tmp/blah) is something handled by the shell, and AFAIK postfix won't invoke a shell to run your command; so yourscripthandler should be something like:

#!/bin/sh
/usr/local/bin/theactualscripthandler >/tmp/dummy
ΤΖΩΤΖΙΟΥ
  • 1,038
  • 1
  • 10
  • 18