Ok,
I will chime in now with your answer,

In your databases create the view to merge users with their aliases:
CREATE ALGORITHM=UNDEFINED definer=`ro...@`localhost` SQL SECURITY 
DEFINER VIEW `dbmail_postfix_map` AS select `dbmail_users`.`userid` AS 
`user`,`dbmail_users`.`passwd` AS `passwd` from `dbmail_users` union 
select `dbmail_aliases`.`alias` AS `alias`,`dbmail_users`.`passwd` AS 
`passwd` from (`dbmail_aliases` join `dbmail_users` 
on((`dbmail_users`.`user_idnr` = `dbmail_aliases`.`deliver_to`)));

I use a full primary email address as my username, but then have 
multiple alliases with full email address pointing to my users.
vult...@netvulture.com (my login)
j...@netvulture.com (alias to user_idnr 5)

The view will let me lookup user='either address' to get the answer.

You will want to have the user created only once, not on both servers, 
otherwise mail will default to the first server listed.

In main.cf:
mydestination = $myhostname, localhost, mail.domain.tld (if dns name 
different than hostname), listofdomainsweacceptmailfor.tlds...
transport_maps = mysql:/etc/postfix/dbmail_relay_transports_server_a.cf, 
mysql:/etc/postfix/dbmail_relay_transports_server_b.cf,
local_recipient_maps = mysql:/etc/postfix/dbmail_mailboxes_server_a.cf, 
mysql:/etc/postfix/dbmail_mailboxes_server_b.cf

If you need to check that a sender is a valid user you will also need:
smtpd_sender_login_maps = 
mysql:/etc/postfix/dbmail_mailboxes_server_a.cf, 
mysql:/etc/postfix/dbmail_mailboxes_server_b.cf


dbmail_mailboxes_server_x.cf:
user = dbmail
password = dbmail
dbname = dbmail
hosts = server_a/b's IP
query = SELECT user FROM dbmail_postfix_map WHERE user='%s'

dbmail_relay_transports_server_x.cf:
user = dbmail
password = dbmail
dbname = dbmail
hosts = server_a/b's IP
query = SELECT 'lmtp:server_a/b_ip:24' FROM dbmail_postfix_map WHERE 
user='%s'

The result is that mail will be directed to the correct lmtp based on 
what user it is destined for.

server_a_u...@domain.tld -> server_a:24
server_b_u...@domain.tld -> server_b:24


Further postfix stuff you might need if you use smtp auth for sending
smtp_sasl_type = cyrus
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes

smtpd_recipient_restrictions =
                            permit_mynetworks,
                            reject_invalid_hostname,
                            reject_non_fqdn_sender,
                            reject_non_fqdn_recipient,
                            reject_unknown_recipient_domain,
                            reject_unauth_pipelining,
                            reject_unknown_sender_domain,
                            permit_sasl_authenticated,
                            reject_rbl_client sbl-xbl.spamhaus.org,
                            reject_rbl_client bl.spamcop.net,
                            check_helo_access hash:/etc/postfix/helo_access,
                            reject_unauth_destination,
                            check_recipient_access hash:/etc/postfix/access,
                            check_policy_service unix:private/policy
smtpd_sender_restrictions =
                            permit_mynetworks,
                            check_helo_access hash:/etc/postfix/helo_access,
                            reject_authenticated_sender_login_mismatch,
                            permit_sasl_authenticated,
                            reject_sender_login_mismatch,
                            reject_unknown_sender_domain,
                            check_sender_access 
hash:/etc/postfix/sender_access


sender_access: (tabs not spaces between key and value)
mydomain.tld   553 not logged in
my2nddomain.tld   553 not logged in
*   OK

sasl2/smtpd.conf:
pwcheck_method: auxprop
auxprop_plugin: sql
allowanonymouslogin: no
allowplaintext: yes
mech_list: PLAIN LOGIN
srp_mda: md5
password_format: crypt
srvtab: /dev/null
opiekeys: /dev/null
sql_engine: mysql
sql_hostnames: server_ip
sql_user: dbmail
sql_passwd: dbmail
sql_database: dbmail
sql_verbose: yes
sql_select: SELECT passwd FROM dbmail_postfix_map WHERE (user) = ('%...@%r')
log_level: 10
sql_verbose: yes


With this setup, all of my users need to use smtp auth to send mail out. 
If someone tries to send mail from one of my valid users with out it, 
the message is rejected with the 553. I can use a helo or network_table 
to allow those matching to send with out auth. Mail coming in un-auth 
must come from some other domain to a valid users bases on the view. For 
simplicity all my users have plaintext passwords. During my last 
upgrade, I lost the ability to get my sasl to match a crypt password and 
had to change.

This should solve your receiving issue. If you have postfix on both 
sites, then you can just have users send through their local postfix to 
solve the problem of the sasl lookup only going to one server.

Let me know how that turns out.

-Jon

George Vieira wrote:
> This doesn't work. As I said, unfortunately in postfix as a normal local user 
> is assumed to be a name and the mailbox_transport_map is passed only the 
> username, so it strips the domain out.
> http://www.irbs.net/internet/postfix/0602/0122.html
>
> The dead giveaway also is the bounce message below (ie accounts not 
> accou...@domain.tld).
> Sep  1 19:32:16 serapis postfix/local[24480]: 7823E6B57: 
> to=<accou...@domain.tld>, relay=local, delay=0.09, delays=0.03/0.04/0/0.03, 
> dsn=5.1..1, status=bounced (unknown user: "accounts")
>
> I even thought i'd try virtual, but virtual is worse as it doesn't actually 
> have a virtal_mailbox_transport_map so I'm stuffed either way.
>
> I have to either change to using username_domain.tld or using subdomain 
> domain_maps and aliases to redirect them. Ie  accou...@domain.tld -> 
> accou...@server1.domain.tld
>
>
> George
> -----Original Message-----
> From: dbmail-boun...@dbmail.org [mailto:dbmail-boun...@dbmail.org] On Behalf 
> Of Jesse Norell
> Sent: Tuesday, 1 September 2009 3:58 AM
> To: DBMail mailinglist
> Subject: Re: [Dbmail] recipient redirect
>
> On Sun, 2009-08-30 at 21:16 +1000, George Vieira wrote:
>   
>> This is where I now run into a snag, mailbox_transport_maps only
>> passes the username part of the email as %s and i cannot get the full
>> email address on this lookup.
>>
>>  
>>
>> # host and port were added to dbmail_users for the transport
>> testing...
>>
>> query = SELECT CONCAT( "dbmail-lmtp:", u.host, ":", u.port ) FROM
>> dbmail_aliases AS a, dbmail_users AS u WHERE alias like "%...@%%" AND
>> deliver_to = u.user_idnr AND active=1 LIMIT 1
>>     
>
>   Maybe try %...@%d (see http://www.postfix.org/mysql_table.5.html).  
>
>   


-- 
Scanned for viruses and dangerous content by MailScanner

_______________________________________________
DBmail mailing list
DBmail@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to