PostFixSQLAliasProblem

From Request Tracker Wiki
Revision as of 00:04, 2 July 2009 by Darkpixel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In my case ive got this error (Example):

postfix/pickup[28293]: 41646618D: uid=0 from=<root>
postfix/cleanup[28375]: 41646618D: message-id=<20050104225650.41646618D@example.net>
postfix/qmgr[3332]: 41646618D: from=<root@example.net>, size=307, nrcpt=7 (queue active)
postfix/qmgr[3332]: 41646618D: to=<--action@example.net>, orig_to=<rt>, relay=none, delay=0, status=bounced (invalid recipient syntax: "--action@example.net")
postfix/qmgr[3332]: 41646618D: to=<--queue@example.net>, orig_to=<rt>, relay=none, delay=0, status=bounced (invalid recipient syntax: "--queue@example.net")
postfix/qmgr[3332]: 41646618D: to=<--url@example.net>, orig_to=<rt>, relay=none, delay=0, status=bounced (invalid recipient syntax: "--url@example.net")
postfix/local[28380]: 41646618D: to=<correspond@example.net>, orig_to=<rt>, relay=local, delay=0, status=bounced (unknown user: "correspond")
postfix/local[28381]: 41646618D: to=<general@example.net>, orig_to=<rt>, relay=local, delay=0, status=bounced (unknown user: "general")
postfix/local[28381]: 41646618D: to=<|/opt/rt3/bin/rt-mailgate@example.net>, orig_to=<rt>, relay=local, delay=0, status=bounced (unknown user: "|/opt/rt3/bin/rt-mailgate")
postfix/local[28382]: 41646618D: to=<http://localhost/@example.net>, orig_to=<rt>, relay=local, delay=0, status=bounced (unknown user: "http://localhost/")
postfix/qmgr[3332]: 41646618D: removed

The solution is to set up virtual aliases that direct virtual addresses to the local delivery agent:

/etc/postfix/main.cf:

virtual_alias_maps = pgsql:/etc/postfix/virtual

Virtual data in SQL database following this idea:

rt@example.com goes to rt
rt-comment@example.com goes to rt-comment

/etc/aliases:

rt: "|/opt/rt3/bin/rt-mailgate --queue general --action correspond --url http://localhost/"
rt-comment: "|/opt/rt3/bin/rt-mailgate --queue general --action comment --url http://localhost/"

PS:

Remeber to do a 'newaliases' command to make the new alias database.

This example assumes that in main.cf, $myorigin is listed under the mydestination parameter setting. If that is not the case, specify an explicit domain name on the right-hand side of the virtual alias table entries or else mail will go to the wrong domain.

More information about the Postfix local delivery agent can be found in the local(8) manual page.

Why does this example use a clumsy virtual alias instead of a more elegant transport mapping? The reason is that mail for the virtual mailing list would be rejected with "User unknown". In order to make the transport mapping work one would still need a bunch of virtual alias or virtual mailbox table entries.

* In case of a virtual alias domain, there would need to be one identity mapping from each mailing list address to itself.
 * In case of a virtual mailbox domain, there would need to be a dummy mailbox for each mailing list address.
 
 

Original explanation from www.postfix.org/VIRTUAL_README.html#mailing_lists

(posting above by Anonymous Gnome)


Postfix 2

I had to install RT in a setup where the only configured mail transport was virtual. I could not get the standard entry in /etc/aliases to work as detailed above.

Setup rt-mailgate using pipe in /etc/postfix/master.cf

#rt
 rt      unix    -       n       n       -       -       pipe
   flags=R user=vmail argv=/opt/rt3/bin/rt-mailgate --queue ${user} --action correspond --url http://example.com/
 
 

Virtual data in database (virtual_alias_maps=mysql:/etc/postfix/virtual.cf) :

rt@example.com goes to rt@localhost
rt-comment@example.com goes to rt-comment@localhost

Virtual Transport (transport_maps):

example.com uses virtual, username=vmail
localhost  uses pipe, username=vmail

In this setup the queue name must be the username (part left of @) for the email address.

-Fahd S.

Postfix 2 Tweaked

I used a slight tweaked method than what Fahd has above. The benefit to my method is that you can send comments instead of just sending correspondence. Also, several other examples throughout the wiki use VERP (the plus sign) in the email address to denote the action which is potentially could be a security issue (Maybe someone could address general+take@example.com or general+merge@example.com...?). I have a virtual-only mail server. No local accounts. I believe my method works much better.

In /etc/master.cf add the following lines: rt unix - n n - - pipe

flags=R user=vmail argv=/opt/rt3/bin/rt-mailgate --queue ${user} --action ${nexthop} --url http://example.com/

The ${user} variable gets replaced with the username part of the email address. The ${nexthop} variable gets replaced by whatever is after 'rt:' below.

In my case, I use /etc/postfix/virtual_transports instead of SQL, but the mappings are the same.

general@example.com rt:correspond general-comment@example.com rt:comment testqueue@example.com rt:correspond testqueue-comment@example.com rt:comment

Remember: Virtual Transports in Postfix don't have to apply to an entire domain, they can apply to specific e-mail addresses as well. This works out well if you want to share your 'example.com' domain with RT in addition to using it as your companies primary domain.

-aaron@darkpixel.com