• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved mail account can not be crated - ERROR:__main__:mails.domain_id may not be NULL

cool_sh

Basic Pleskian
Hi there,

I have a problem creating a new mail account:

Error: mailmng-outgoing failed: ERROR:__main__:mails.domain_id may not be NULL

Already checked some KB articles like
OR

Those do not help and "plesk repair db" has nothing to fix.


But I am experiencing the error as well when trying "plesk repair mail <domainname>"

Code:
plesk repair mail mail@<domainname>

Repairing the mail server configuration
    Reconfiguring the mailboxes ..................................... [2020-11-16 19:04:53.427] ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/mailname_repair'] with exit code [1]
[FAILED]
    - mailname_repair failed: Restoring mailbox settings for
      test@<domainname>
      DEBUG setMailboxQuota(..., 85899345920)
      Clean virtual aliasing settings for test@<domainname>
      Restoring auth settings for test@<domainname>
      Restoring antivirus settings for test@<domainname>
      Restoring antispam handlers for test@<domainname>
      Restoring autoresponder handler for test@<domainname>
      Restoring autoresponder database settings for test@<domainname>
      Restoring greylist settings for test@<domainname>
      Restoring virtual aliasing for test@<domainname>
      Restoring responder attachments info for test@<domainname>
      Restoring antispam settings for test@<domainname>
      Restoring spamassassin .qmail options
      Restoring outgoing limits for test@<domainname>
      mails.domain_id may not be NULL
      ERROR:__main__:This exception happened at:
      Traceback (most recent call last):
        File
      "/usr/local/psa/admin/sbin/mailname_repair/mailname_repair.py",
      line 152, in main
        File
      "/usr/local/psa/admin/sbin/mailname_repair/mailname_repair.py",
      line 68, in restore_outgoing_limits
        File
      "/usr/local/psa/admin/sbin/mailname_repair/plesk_outgoing_mail_db.py",
      line 320, in create_mailname
          mail_name, domain_name).rowcount
        File
      "/usr/local/psa/admin/sbin/mailname_repair/plesk_sqlite3_db.py",
      line 139, in run
          return conn.execute(query, params)
      IntegrityError: mails.domain_id may not be NULL

Error messages: 0; Warnings: 0; Errors resolved: 0

exit status 1

Any additional idea how to fix this?
 
Last edited:
Hello VNick,

Code:
[~] plesk repair mail

Repairing the mail server configuration

  Reconfigure all domains and mailboxes? [Y/n] y
    Reconfiguring all domains and mailboxes ......................... [OK]

Error messages: 0; Warnings: 0; Errors resolved: 0

but the problem still remains.
 
Check the article Igor posted above. If the last symptom is not present, this might be a previously unknown issue, in which case you're advised to address Plesk support.
 
I have the same issue -- here it goes:

# plesk repair db -v

Checking the Plesk database using the native database server tools

Run query: CHECK TABLE accounts

Run query: CHECK TABLE actions

Run query: CHECK TABLE admin_aliases


etc.. it finishes without any problems.

Error messages: 0; Warnings: 0; Errors resolved: 0


[root@jedi gateways]# plesk repair mail somedomain.com


Repairing the mail server configuration

Reconfiguring the settings of domains: somedomain.com ......... [OK]

Reconfiguring the mailboxes ..................................... [2020-11-26 05:00:11.471] ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/mailname_repair'] with exit code [1]

[FAILED]

- mailname_repair failed: Restoring mailbox settings for

[email protected]

DEBUG setMailboxQuota(..., 1048576000)

Clean virtual aliasing settings for

[email protected]

Restoring auth settings for [email protected]

Restoring antivirus settings for

[email protected]

Restoring antispam handlers for

[email protected]

Restoring autoresponder handler for

[email protected]

Restoring autoresponder database settings for

[email protected]

Restoring greylist settings for

[email protected]

Restoring virtual aliasing for

[email protected]

Restoring responder attachments info for

[email protected]

Restoring antispam settings for

[email protected]

Restoring spamassassin .qmail options

Restoring mailbox settings for [email protected]

DEBUG setMailboxQuota(..., 1048576000)

Clean virtual aliasing settings for [email protected]

Restoring auth settings for [email protected]

Restoring antivirus settings for [email protected]

Restoring antispam handlers for [email protected]

Restoring autoresponder handler for [email protected]

Restoring autoresponder database settings for

[email protected]

Restoring greylist settings for [email protected]

Restoring virtual aliasing for [email protected]

Restoring responder attachments info for

[email protected]

Restoring antispam settings for [email protected]

Restoring spamassassin .qmail options

Restoring mailbox settings for [email protected]

DEBUG setMailboxQuota(..., 1048576000)

Clean virtual aliasing settings for [email protected]

Restoring auth settings for [email protected]

Restoring antivirus settings for [email protected]

Restoring antispam handlers for [email protected]

Restoring autoresponder handler for [email protected]

Restoring autoresponder database settings for

[email protected]

Restoring greylist settings for [email protected]

Restoring virtual aliasing for [email protected]

Restoring responder attachments info for [email protected]

Restoring antispam settings for [email protected]

Restoring spamassassin .qmail options

Restoring outgoing limits for [email protected]

mails.domain_id may not be NULL

ERROR:__main__:This exception happened at:

Traceback (most recent call last):

File

"/usr/local/psa/admin/sbin/mailname_repair/mailname_repair.py",

line 152, in main

File

"/usr/local/psa/admin/sbin/mailname_repair/mailname_repair.py",

line 68, in restore_outgoing_limits

File

"/usr/local/psa/admin/sbin/mailname_repair/plesk_outgoing_mail_db.py",

line 320, in create_mailname

mail_name, domain_name).rowcount

File

"/usr/local/psa/admin/sbin/mailname_repair/plesk_sqlite3_db.py",

line 139, in run

return conn.execute(query, params)

IntegrityError: mails.domain_id may not be NULL


Error messages: 0; Warnings: 0; Errors resolved: 0



exit status 1


this doesnt help either.. blank output:


# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -Nse "SELECT d.name FROM domains d JOIN DomainServices ds on d.id=ds.dom_id LEFT JOIN IpAddressesCollections ipc on (ds.ip

CollectionId = ipc.ipCollectionId ) WHERE ds.type='mail' AND ipc.ipCollectionId is NULL"

[root@jedi gateways]#
 
Last edited:
Run full plesk repair mail to fix.
Beware that this is a painful command if you have thousands of mail addresses -- who cannot login during the hour it takes for this command to run.

I just ran this command it ended like this:

[root@jedi gateways]# plesk repair mail
Repairing the mail server configuration
Reconfigure all domains and mailboxes? [Y/n]
Reconfiguring all domains and mailboxes .........................

PHP Warning: Error while sending QUERY packet. PID=46191; File: /usr/local/psa/admin/plib/vendor/plesk/zf1/library/Zend/Db/Statement/Pdo.php, Line: 228
PHP Warning: Error while sending QUERY packet. PID=46191 in /usr/local/psa/admin/plib/vendor/plesk/zf1/library/Zend/Db/Statement/Pdo.php on line 228
[OK]

Error messages: 0; Warnings: 0; Errors resolved: 0
[root@jedi gateways]#

Now the mail service does not allow anyone to login. even after a reboot..
Running plesk repair mail <domainname> for every domain manully now in hopes that that will fix the mailbox passwords, etc.
 
Last edited:
For the issue, you could check if you have problems in the psa database like
select * from mail WHERE (dom_id LIKE '') OR (dom_id LIKE NULL);
It's not the same database, but the NULL field content has to originate somewhere, so maybe it helps to check the psa.mail table for it.

For logins: I'd be interested in knowing what error messages is logged when a login attempt is made.
 
For the issue, you could check if you have problems in the psa database like
select * from mail WHERE (dom_id LIKE '') OR (dom_id LIKE NULL);
It's not the same database, but the NULL field content has to originate somewhere, so maybe it helps to check the psa.mail table for it.

For logins: I'd be interested in knowing what error messages is logged when a login attempt is made.
hi.. thank you for your reply. Here is what I get now:

MariaDB [psa]> select * from mail WHERE (dom_id LIKE '') OR (dom_id LIKE NULL);
Empty set (0.001 sec)

However I am unable to try the login error message as the problem has gone away after much "plesk repair mail " commands, and mchk commands.
 
Sorry for the late replay.
The problem was fixed using the solution which IgorG mentioned above for Plesk "Obsidian 18.0.28 and earlier" - as well as the problem wasn't existing in this version and popped up by a younger update.

In detail:
The issue was in inconsistency of Plesk database. Missed records in table `IpAddressesCollections.
Code:
# plesk db -Ne "select ds.ipCollectionId,dp.val from DomainServices
ds left join IpAddressesCollections ipc on (ds.ipCollectionId = ipc.ipCollectionId) inner
join domains d on (ds.dom_id = d.id) left join dom_param dp on (d.id = dp.dom_id and
dp.param = 'ip_addr_id') where ipc.ipAddressId is null"
    10      1
     6      1

So they were added back:

mysql> insert into IpAddressesCollections values (10,1);
     Query OK, 1 row affected (0.00 sec)

mysql> insert into IpAddressesCollections values (6,1);
     Query OK, 1 row affected (0.00 sec)

And repaired mail settings:

# plesk repair mail -y

    Repairing the mail server configuration
        Reconfiguring all domains and mailboxes ......................... [OK]

    Error messages: 0; Warnings: 0; Errors resolved: 0

The creation of a new mail account without issue was possible again.
 
Sorry for the late replay.
The problem was fixed using the solution which IgorG mentioned above for Plesk "Obsidian 18.0.28 and earlier" - as well as the problem wasn't existing in this version and popped up by a younger update.

In detail:
The issue was in inconsistency of Plesk database. Missed records in table `IpAddressesCollections.
Code:
# plesk db -Ne "select ds.ipCollectionId,dp.val from DomainServices
ds left join IpAddressesCollections ipc on (ds.ipCollectionId = ipc.ipCollectionId) inner
join domains d on (ds.dom_id = d.id) left join dom_param dp on (d.id = dp.dom_id and
dp.param = 'ip_addr_id') where ipc.ipAddressId is null"
    10      1
     6      1

So they were added back:

mysql> insert into IpAddressesCollections values (10,1);
     Query OK, 1 row affected (0.00 sec)

mysql> insert into IpAddressesCollections values (6,1);
     Query OK, 1 row affected (0.00 sec)

And repaired mail settings:

# plesk repair mail -y

    Repairing the mail server configuration
        Reconfiguring all domains and mailboxes ......................... [OK]

    Error messages: 0; Warnings: 0; Errors resolved: 0

The creation of a new mail account without issue was possible again.
Many thanks.. that SELECT command brings pages and pages of output to me.. you only had 2 missing entries, lucky! Shall I really add all that into the database? Scared..
 
Back
Top