Here you go, first set are what I use in production with the
relay_domains method.  I should note that I wrote my own
PlPgSQL function to check if a user is valid.  I check the users
table, then the alias table, plus I added a column that lists a
user as "active" such that if they don't pay, they can't get Email.

#
# postgresql config file for alias lookups on postfix
# comments are ok.
#

# the user name and password to log into the pgsql server
user = abc123
password = sshhhh

# the database name on the servers
dbname = dbmail

# the table name
table = dbmail_users

query = SELECT valid_email FROM valid_email('%s') WHERE valid_email =
'OK'

# the hosts that postfix will try to connect to
# and query from (in the order listed)
hosts = host1

# end postgresql config file



Well it appears that I no longer have my old virtual_mailboxes
setup at home.  Basically I had two pgsql files, one that simply
checked the domains (I got this info from my pdns server, but
you could easily add a dbmail_domains table).  The other file
is simply the lookup for the user name in the dbmail_users table.
Of course looking back on it, I probably wasn't checking the
aliases which was bad.

The only way I could figure to check the aliases AND the users
was to do a function.  I'm a big fan of those and why I use
postgres.  We write functions to do pretty much everything,
imbed all the logic in the db we can, so we have maximum
flexibility with software.  I'm sure someone will tell me a
better way now that I post this.

Actually I just had a really good idea that you might want to
explore.  If you use check_client_access function in your
smtpd_recipient_restrictions section, you could use a pgsql
lookup that returns OK or REJECT for a given username, or
domain.

I still think you should be able to use a pgsql file for relay_domains.
You might want to check your version of postfix to see if a newer
one supports that.

--
David A. Niblett               | email: [EMAIL PROTECTED]
Network Administrator          | Phone: (352) 334-3400
Gainesville Regional Utilities | Web: http://www.gru.net/



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of andy
Sent: Thursday, January 12, 2006 12:59 AM
To: DBMail mailinglist
Subject: RE: [Dbmail] Postfix & DBMail (Plus Reject messages)



Hello David

That has been very helpful thank you :). 

Just for my own records, is there any chance you could copy and paste
your pgsql files? (domains, users and virtual ones). It would be very
useful just to check mine against yours since I'm using your recommended
settings for the main.cf file.

Much appreciated your help so far.

Kind Regards,
Andy Savage

On Mon, 9 Jan 2006 15:42:40 -0500, "Niblett, David A"
<[EMAIL PROTECTED]> wrote:
> Sorry for that late reply, holiday madness around here.
> 
> I had to go digging to find the setup I had with Virtual Domains.  
> This works too, I use it at home, it was my first attempt at Postfix 
> and DBMail.  I have several domains:
> 
> virtual_mailbox_base = /virtual/mail
> virtual_mailbox_domains = pgsql:/etc/postfix/pgsql-domains.cf
> virtual_mailbox_maps = pgsql:/etc/postfix/pgsql-users.cf virtual_maps 
> = pgsql:/etc/postfix/pgsql-virtual.cf
> transport_maps = hash:/etc/postfix/transport 
> transport_destination_recipient_limit = 1
> 
> I believe you can make the transport maps as a pgsql select to grab 
> only the @domain.name portion and hard code the dbmail-lmtp transport 
> part in the select.
> 
> To be honest I don't really get the difference between virtual_mailbox

> and relay_domains.  I just recall reading somewhere that relay_domains

> was prefered over virtual_mailbox.  Regardless, you should be able to 
> provide a pgsql:xxxx for the relay_domains option per: 
> http://www.postfix.org/uce.html#relay_domains
> 
> The code to do virtual_mailbox_domains is practically identical to 
> relay_domains, so I'm not sure why it didn't work for you.  Just 
> remember it has to return 2 columns, the first being the domain and 
> the second being "something".  Postfix doesn't care, but it has to get

> something there or else it's unhappy.
> 
> Got any log output when you try this?  Especially useful is to use 
> debug_peer = <IP> and set the debug level high.  Then you can connect 
> from a specific IP (the one listed) and Postfix will puke up TONS of 
> logs about what exactly it's trying to do with the delivery.
> 
> --
> David A. Niblett               | email: [EMAIL PROTECTED]
> Network Administrator          | Phone: (352) 334-3400
> Gainesville Regional Utilities | Web: http://www.gru.net/
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
> Behalf Of Andy Savage
> Sent: Thursday, December 29, 2005 6:12 PM
> To: DBMail mailinglist
> Subject: Re: [Dbmail] Postfix & DBMail (Plus Reject messages)
> 
> 
> Thanks David, but one more thing I need to ask.
> 
> I am interested in having everything stored in the database, so I 
> don't
> want to store relay_domains in the config file. What would be the 
> correct way to proxy that to mysql and what would my query look like? 
> Lets say I have a seperate table called postfix_domains.
> 
> You see I am accepting mail for many domains and it makes it much 
> easier
> 
> having everything in the database.
> 
> Also, can I ask, what is the difference between relay_domains and
> virtual_domains?
> 
> Kind Regards,
> Andy Savage
> 
> Niblett, David A wrote:
>> Andy,
>> 
>> I was on the same path as you.  Since you are going to use dbmail 
>> lmtp for delivery I found you need to use relay_domains.
>> 
>> This is what I do:
>> 
>> relay_domains = domain.com
>> relay_recipient_maps = 
>> proxy:pgsql:/sql-configs/postfix-relay-pgsql.cf
>> relay_transport = dbmail-lmtp:[127.0.0.1]:24
>> 
>> 
>> That was all I needed to get everything to work and reject messages.
>> I HIGHLY suggest you use a 550 to reject the Email. By using a 450
you
> 
>> are telling the other end that it's a soft error and to try again
>> later.  550 tells the sender, it doesn't exist, and to not try again.
> 
>> By doing a 450, you will just clog up the sender and they will just
>> eat more bandwidth and CPU hitting you again (most likely every ~15m 
>> for 5d).
>> 
>> --
>> David A. Niblett               | email: [EMAIL PROTECTED]
>> Network Administrator          | Phone: (352) 334-3400
>> Gainesville Regional Utilities | Web: http://www.gru.net/
>> 
>> 
>> 
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>> Behalf Of Andy Savage
>> Sent: Thursday, December 29, 2005 7:01 AM
>> To: dbmail@dbmail.org
>> Subject: [Dbmail] Postfix & DBMail (Plus Reject messages)
>> 
>> 
>> Hey guys
>> 
>> I'm trying to combine DBMail with Postfix and basically I need your
>> help!
>> 
>> I'm after 3 things as I'm having a few troubles currently and was 
>> wondering if some kind soul on the list could help me out.
>> 
>> I need the main.cf configuration for postfix to allow postfix to 
>> check whether a valid recipient exists in the dbmail database and if 
>> it doens't send a 450 reject message back to the user. I don't want 
>> to
> even
>> 
>> accept mail for unknown users, it just burdens my mailserver.
>> 
>> Currently I have:
>> ------------------main.cf----------------
>> myhostname = server.domain.tld
>> alias_maps = hash:/etc/aliases
>> alias_database = hash:/etc/aliases
>> myorigin = /etc/mailname
>> mydestination = $myhostname, localhost, localhost.localdomain
>> relayhost = mynetworks = 127.0.0.0/8 mailbox_command = 
>> mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all
>> 
>> mydestination = mysql:/etc/postfix/mysql-transport.cf
>> local_recipient_maps = mysql:/etc/postfix/mysql-localusers.cf
>> transport_maps = mysql:/etc/postfix/mysql-transport.cf
>> 
>> local_transport = dbmail-lmtp:
>> 
>> smtpd_recipient_restrictions = 
>> permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
>> smtpd_use_tls = yes
>> smtpd_tls_cert_file = /etc/postfix/smtpd.cert smtpd_tls_key_file = 
>> /etc/postfix/smtpd.key unknown_local_recipient_reject_code = 450
>> -----------------------------------------
>> 
>> Kind Regards,
>> Andy Savage
>> _______________________________________________
>> Dbmail mailing list
>> Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail
>> _______________________________________________
>> Dbmail mailing list
>> Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail
> _______________________________________________
> Dbmail mailing list
> Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail
> _______________________________________________
> Dbmail mailing list
> Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail

_______________________________________________
Dbmail mailing list
Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail

Reply via email to