CREATEVIEWpostfix_virtualASSELECTm.username||'@'||d.domainAS userid, a.alias||'@'||d.domainAS address
FROM vmails_domain d, vmails_alias a, vmails_mailbox m
WHEREa.mailbox_id=m.idANDm.domain_id=d.idUNION ALLSELECTm.username||'@'||d.domainAS userid, m.username||'@'||d.domainFROM vmails_domain d, vmails_mailbox m WHEREm.domain_id=d.id;
CREATEVIEWpostfix_mailboxesASSELECTm.username||'@'||d.domainAS userid, d.domain||'/'||m.username||'/'AS mailbox
FROM vmails_domain d, vmails_mailbox m
WHEREm.domain_id=d.idUNION ALLSELECTd.domainAS userid, 'dummy'AS mailbox
FROM vmails_domain d;
CREATEVIEWdovecot_usersASSELECTm.username||'@'||d.domainAS mailbox, m.password, '/home/vmail/'||d.domain||'/'||m.usernameAS home
FROM vmails_mailbox m, vmails_domain d
WHEREm.domain_id=d.id;
GRANTSELECTON postfix_mailboxes, postfix_virtual, dovecot_users, vmails_alias,
vmails_domain, vmails_mailbox TO mailreader;