Connection to Postfix



  • Hi,
    as far as I understood right (and as it works for me) Postfix uses virtualtransport for moving incoming mails to the Kopano dagent, which listens on Port 2003 (default).

    So, in Posfix main.cf I have the following settings concerning the virtual users / transport.

    virtual_mailbox_maps = hash:/etc/postfix/virtual
    virtual_alias_maps = hash:/etc/postfix/virtual
    virtual_transport = lmtp:127.0.0.1:2003
    

    As you can see, I only use flatfile (virtual) for my mailboxes and aliases.

    How does Kopano know, where incoming emails have to be assigned to? Does it check the kopano-users in kopano-db -> looking up the emailaddresses -> then assigns the incoming mail to the user with the matching emailaddress?

    (I am using users which are added via kopano-admin. The users are stored in die Kopano-db)

    Thanks for your answers!


  • Kopano

    Hello @mcdaniels ,

    dagent can accept deliveries either to the primary email address of the user, or the username of a user.



  • Personally I am using the following config with postfix to validate kopano db users:

    virtual_alias_maps = hash:/etc/postfix/virtual
    virtual_mailbox_domains = mysql:/etc/postfix/kopano-domains.conf
    virtual_mailbox_maps = mysql:/etc/postfix/kopano-users.conf
    virtual_transport = lmtp:localhost:2003
    

    And kopano-domains.conf

    user = <db user>
    password = <db pass>
    hosts = <db host>
    dbname = <db name>
    query = select value from objectproperty where objectid=(select objectid from objectproperty where value LIKE '%%@%s' and propname='emailaddress' limit 1) and propname='loginname';
    

    kopano-users.conf with the same except for query

    query = select value from objectproperty where objectid=(select objectid from objectproperty where value='%s' and propname='emailaddress' limit 1) and propname='loginname';
    

    They are modified from the documentation since I need to check for the e-mail address (different domains on the system) and not the userrname.



  • Hello,
    @fbartels - Thanks!

    @bosim Thank you for the examples.
    It seems like that I know, what Postfix/Kopano is doing if I use this config:

    virtual_mailbox_maps = hash:/etc/postfix/virtual
    virtual_alias_maps = hash:/etc/postfix/virtual
    

    Mail comes in, Postfix checks the maps -> hands it over to dagent (with the emailaddress) -> so it is assigned to the correct kopano-db-user.

    Your SQL query for the kopano-domains deliver only the username. (If I use it the right way):

    select value from objectproperty where objectid=(select objectid from objectproperty where value LIKE '%%@%s' and propname='emailaddress' limit 1) and propname='loginname';
    

    Output is a Username, but should be the domain?

    I am sure I have a wrong understanding of it…



  • Good morning,
    …just playing around a little bit with mysql-queries.

    I wonder if the following query would be enough for postfix to check if a mailaddress is existing in kopano-db.

    SELECT value FROM objectproperty where propname = 'emailaddress' and value = '%s'
    

    edit: the query seems to work.



  • Great you got it working. The wierd %s@%s logic is to take out the domains not the users.

    Bo


Log in to reply