Relay access denied after server migration with ispconfig migration toolkit

Discussion in 'ISPConfig 3 Priority Support' started by kommid, Aug 6, 2025.

  1. kommid

    kommid Member HowtoForge Supporter

    I migrated one of our ISPConfig servers to a new machine using the ISPConfig Migration Toolkit according to this tutorial https://www.howtoforge.com/tutorial...-confixx-plesk-to-ispconfig-31-single-server/.
    Everything seemed to have gone fine, except email:
    When I send an email to a mailbox on the new server, the mail bounces with this error message: "Relay access denied (in reply to RCPT TO command)"
    DNS-entries are correct and with one domain, that had only one catch all forward, I tried deleting and re-creating the domain on the server, which did work, but I don't want to re-create all email-domains on the server. This would also involve re-creating quite a lot of mailboxes and forwards....
    Any Idea, what the problem could be here and how I could fix it?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Is this a single server or a multiserver setup?
    2) Did you had any errors in the migrate.log file during migration?
    3) Do the domains and mailboxes show up in the GUI of the new ISPConfig system?
     
  3. kommid

    kommid Member HowtoForge Supporter

    It's a single server setup
    I just skimmed the log at the end of the migration and deleted it. I didn't notice any errors, maybe I should have had a closer look... :(
    The domains show up in the GUI and everything looks ok.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, then try to run Tools > Resync on the email domains and mailboxes to see if this fixes the issue.
     
  5. kommid

    kommid Member HowtoForge Supporter

    Unfortunately, this didn't fix the issue. when I delete a domain in the GUI, the email-addresses attached to it will be deleted too, but will the mailbox directories in my vmail directory be deleted as well? I just had a closer look and it's not so many mailboxes, it's mainly forwards, and those are set up fairly quick....
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes, If you would delete an email domain, then this would delete the email mailbox. I do not recommend deleting mailboxes or domains in your case.

    Do the forwards that do not work show up in ISPConfig GUI?
     
  7. kommid

    kommid Member HowtoForge Supporter

    yes, the GUI looks completely normal, everything is there. I also tried opening and saving a domain, a mailbox and a forward, but this didn't help either
     
  8. pyte

    pyte Well-Known Member HowtoForge Supporter

    What is the result of running this command with a mailbox that is shown in the Mailbox section of the ISPConfig GUI?
    Code:
     postmap -q [email protected] proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
    Forwards you can check with:
    Code:
     postmap -q [email protected]  proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf
     
    till likes this.
  9. kommid

    kommid Member HowtoForge Supporter

    postmap -q [email protected] proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf returns mailbox.com/[email protected]/
    postmap -q [email protected] proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf returns the email addresses, the forward is pointing to.
    The problem seems to be, that the server doesn't feel in charge for the domains listed in the Email Domain section of the gui.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Maybe your server setup has an issue with the server_id so that the records have a different server ID than the current server. If its a single server, they should have server_id = 1 and the server should use server_id = 1 as its ID.
     
  11. kommid

    kommid Member HowtoForge Supporter

    where can I see and set the server_id?
     
  12. pyte

    pyte Well-Known Member HowtoForge Supporter

    If I understood this correctly none of the configured domains and mailboxes work, but if that postmap query works, that would mean that the entry for "[email protected]" is present in the database, with the correctly configured `server_id` field, as the query checks for the `server_id`.
    So either the `mail_domain` table entries differ and don't have the correct `server_id` or something in your postfix main.cf is messed up.
    Did you make any changes to the postfix configuration files or do you use a custom-conf template for postfix?

    And you can check if the domain is a valid domain with:
    Code:
     postmap -q yourdomain.com mysql:/etc/postfix/mysql-virtual_domains.cf
     
  13. kommid

    kommid Member HowtoForge Supporter

    postmap -q yourdomain.com mysql:/etc/postfix/mysql-virtual_domains.cf (with my domainname of course :)) returns nothing, so I assume, it's ok?
     
  14. pyte

    pyte Well-Known Member HowtoForge Supporter

    No it's not ok and that most likely is the issue. It should return the domain you query for - if that query does not work, postfix will not accept any mail for the domain you queried.

    Can you provide us with the content of the files (Dont show the Username, Password):
    • /etc/postfix/mysql-virtual_domains.cf
    • /etc/postfix/mysql-virtual_mailboxes.cf
    • /etc/postfix/mysql-virtual_forwardings.cf
    And can you please check the database:
    Code:
    # mysql -u root -p dbispconfig
    
    -> select domain_id, server_id, domain from mail_domain where domain = "yourdomain.tld" limit 1;
    
    -> select mailuser_id, server_id, email from mail_user where email like "%yourdomain.tld" limit 1;
     
  15. kommid

    kommid Member HowtoForge Supporter

    I just had a look into dbispconfig. In the server table, the server has ID=1 and in the email_domain table, all domains are assigned to Server ID 1
     
  16. kommid

    kommid Member HowtoForge Supporter

    /etc/postfix/mysql-virtual_domains.cf:
    Code:
    user = xxx
    password = xxx
    dbname = dbispconfig
    hosts = 127.0.0.1
    query = SELECT domain FROM mail_domain WHERE domain = '%s' AND active = 'y' AND local_delivery = 'y' AND server_id = 1
               AND NOT EXISTS (SELECT source FROM mail_forwarding WHERE source = '@%s' AND type = 'aliasdomain' AND active = 'y' AND server_id = 1)
    /etc/postfix/mysql-virtual_mailboxes.cf:
    Code:
    user = xxx
    password = xxx
    dbname = dbispconfig
    hosts = 127.0.0.1
    query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM mail_user WHERE email = '%s' AND postfix = 'y' AND disabledeliver = 'n' AND server_id = 1
               AND EXISTS (SELECT domain_id FROM mail_domain WHERE domain = SUBSTRING_INDEX('%s', '@', -1) AND active = 'y' AND server_id = 1)
    
    /etc/postfix/mysql-virtual_forwardings.cf
    Code:
    user = xxx
    password = xxx
    dbname = dbispconfig
    hosts = 127.0.0.1
    query = SELECT s.destination AS target FROM mail_forwarding AS s
                WHERE (s.source = '%s' OR s.source = CONCAT(SUBSTRING_INDEX('%u', '+', 1), '@%d')) AND s.type IN ('alias', 'forward') AND s.active = 'y' AND s.server_id = 1
            UNION
            SELECT s.destination AS target FROM mail_forwarding AS s
                WHERE s.source = '@%d' AND s.type = 'catchall' AND s.active = 'y' AND s.server_id = 1
                AND NOT EXISTS (SELECT email FROM mail_user WHERE (email = '%s' OR email = CONCAT(SUBSTRING_INDEX('%u', '+', 1), '@%d')) AND EXISTS (SELECT domain_id FROM mail_domain WHERE domain = SUBSTRING_INDEX('%s', '@', -1) AND active = 'y' AND server_id = 1) AND server_id = 1)
                AND NOT EXISTS (SELECT source FROM mail_forwarding WHERE (source = '%s' OR source = CONCAT(SUBSTRING_INDEX('%u', '+', 1), '@%d')) AND active = 'y' AND server_id = 1)
    
    select domain_id, server_id, domain from mail_domain where domain = "yourdomain.tld" limit 1;
    returns:
    domain_Id=1, server_id=1, domain=yordomain.tld

    select mailuser_id, server_id, email from mail_user where email like "%yourdomain.tld" limit 1;
    returns:
    mailuser_id=7, server_id=1, [email protected]
     
  17. pyte

    pyte Well-Known Member HowtoForge Supporter

    The only reasonable explanation why this returns nothing when the details you provided are correct is that this part of the query returns something:
    Code:
    (SELECT source FROM mail_forwarding WHERE source = '@%s' AND type = 'aliasdomain' AND active = 'y' AND server_id = 1)
    Do you have a entry in the Aliasdomain section in ISPConfig for "yourdomain.com"?
     
  18. kommid

    kommid Member HowtoForge Supporter

    No there weren't any Aliasdomains. But since this is a rather small server and it was late, I just started a new migration yesterday and this morning, when I came back to my office, the migration was done and everything seems to work. Don't know, what went wrong the first time but now everything seems to be up and running.
    Thank you so much for your support :)
     
  19. pyte

    pyte Well-Known Member HowtoForge Supporter

    Still confused about what caused this issue, as the information you provided seem completely fine to me, but I'm glad it works now.
     

Share This Page