Restore to Mailbox not working when using auditor-user only works with personal users

Issue #1247 resolved
trythis created an issue

I use Mailpiler not only to have an archive but also a Backup of all the emails.. so I would love to bulk-restore usign the auditor-user or at least restore users emails to their inbox wihtout loggin me in to all the accounts manually..

so.. what do I need to configure to make the auditor user abel to do that?

Comments (36)

  1. Janos SUTO repo owner

    The auditor user should be able to restore the given email to any email address. Just click on the restore link or icon, and specify the recipient. Also be sure to set the SMARTHOST variable in config-site.php properly.

  2. trythis reporter

    can I somehow use an account with a password for this? one I would define in “config-site.php”

  3. Janos SUTO repo owner

    So you want to use authenticated smtp connection to restore the emails. In that case please show me AUTH mechanisms the smarthost supports.

    Another solution might be to install postfix running on the localhost. Then configure it t use an appropriate authentication towards the smarthost, and finally configure the piler gui to use smarthost=127.0.0.1.

  4. trythis reporter

    Just to make sure we speak of the same thing. I want to use one user which is used just by the “auditor”-user to restore emails for any user. the users can restore their email with their normal password.

    My Mail Server supports plain password over tls.

  5. Janos SUTO repo owner

    I’m sorry for the late response, however, I still don’t get it. Please clarify if the restore funcationality works from the gui. But I have the feeling that you want to restore a user’s emails to his mailbox without using the gui with a special role for this purpose. Am I getting closer?

  6. trythis reporter

    I try to clarify :)

    So..

    If a user logs himself into his own account on piler he can restore his emails to his mailbox.

    If I log myself into the auditor-user. I can see download emails from all users but I cannot restore them into their inbox. → but I want to be able to do so.

  7. Janos SUTO repo owner

    When you click on the specified message you want to restore, then are the recipients' domains in the domain table in the piler mysql database?

    Also when you select several messages with the checkbox on the left side can you restore the messages to the recipient of choice?

  8. Janos SUTO repo owner

    OK, I get it. But I asked you whether the recipients domains are in the domain table?

  9. Janos SUTO repo owner

    In the piler mysql database. Also under the administration / domain menu when you login as an admin user.

  10. Janos SUTO repo owner

    It’s odd. When I select a message as an auditor and the domain of the message recipient’s address is not present in the domain table, then I get a small glitch on the gui. However, when it is, then I can see a checkbox with the email address.

  11. trythis reporter

    since I updated the Piler-Installation I also get this checkbox and it says “restored”. But it’s not. The restore only really works when I’m logged in as the user on mailpiler.

  12. trythis reporter

    you cannot see any problem on screenshots, as it looks as if its working but its not.

    so when I do the restore usignt he “built-in piler auditor” it will allo wme to select the reciever of the restore and then after clicking the restore-button it says “restored” but it’s not.. when I do the resotr while logging in myself as the user on piler, the restore just works.

  13. Janos SUTO repo owner

    OK. Let’s dig a bit deeper. Run “ngrep -X port 25” on the archive when you restore as the auditor, and let’s check the smtp transaction. I’m interested in particularly the smarthost’s reponses. Also check the mail logs on the smarthost. There must be some error.

  14. Janos SUTO repo owner

    You login to the archive host using ssh or similar, install ngrep package if it’s not there, and run ngrep.

  15. trythis reporter

    On my Mailserver I get:

    13.12.2022, 13:40:36    err imap(525644): Error: auth-master: login: request [3459252225]: Login auth request failed: Authenticated user not found from userdb, auth lookup id=3459252225 (auth connected 1 msecs ago, request took 1 msecs, client-pid=525643 client-id=1)
    13.12.2022, 13:40:36    err auth: Error: plain(auditor@local,10.255.255.7,<Dj8fe8fe9//9D>): user not found from any userdbs
    

  16. Janos SUTO repo owner

    OK, we finally nailed it. You enabled IMAP restore, however, the auditor@local account doesn’t exist in the imap database. So either promote a real account as auditor or use smtp to restore emails.

  17. trythis reporter

    so how do I promote my real account to be an auditor, if I still want to use the IMAP feature to check the password?

  18. Janos SUTO repo owner

    Use the CUSTOM_EMAIL_QUERY_FUNCTION feature, see the below example

    $config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'my_custom_func';
    
    function my_custom_func($username = '') {
       $session = Registry::get('session');
       $data = $session->get("auth_data");
    
       if($username == 'some@user') {
          $data['admin_user'] = 2;
       }
    
       $session->set("auth_data", $data);
    }
    

  19. Janos SUTO repo owner

    Fix the if condition something like this:

    $auditors = ['user1@domain','user2@domain',....];
    
    if(in_array($username, $auditors)) {
       $data['admin_user'] = 2;
    }
    

  20. trythis reporter

    I just figured out that it doesnt work. it doesnt matter which E-Mail I restore it will always end up just in my mailbox (the mailbox of the auditor), even though I select another receiver.

  21. Janos SUTO repo owner

    It makes sense, because you set imap restore. I suggest to fix the settings to use SMTP restore. Btw. I wonder why don’t you let users to restore their own emails when they need it?

  22. Log in to comment