Menu

help with variables for maildir_name_hook

2017-05-20
2017-05-20
  • Thomas Boehm

    Thomas Boehm - 2017-05-20

    Hi all,

    I'm trying to add ":LAYOUT=fs" to the end of the value in the maildir column of the mailbox table. It looks like maildir_name_hook does exactly what I want. I put this in my config.local.php

    $CONF['maildir_name_hook'] = 'layout_fs';
    function layout_fs($domain, $user) {
        $layout = ":LAYOUT=fs";
        return sprintf("%s/%s/%s", $domain, $user, $layout);
    }
    

    It works, but $user contains the domain too. Is there another variable I can use instead which only contains the local part of $user? If not, what string operation can I use to cut everything from the @ of $user?

    I tried

    function layout_fs($domain, $user) {
        $layout = ":LAYOUT=fs";
        $dir = before('@', '$user');
        return sprintf("%s/%s/%s", $domain, $dir, $layout);
    }
    

    but when adding the mailbox I only get a white page and the mailbox is not added.

    Thanks
    Thomas

     
  • Thomas Boehm

    Thomas Boehm - 2017-05-20

    Solved it after a bit more research.

    $dir = substr($user, 0, strpos($user, '@'));
    

    seems to work.

    If someone's wondering, what I'm trying to do. I want to use '/' as separator instead of the default '.'

    Edit: It doesnt work as expected. Now new emails are delivered to a file called ":LAYOUT=fs" in the root of the virtual mailbox. I guess I need to configure it in Dovecot directly.

     

    Last edit: Thomas Boehm 2017-05-21

Log in to post a comment.

MongoDB Logo MongoDB