Applicable to:
- Plesk for Windows
- Plesk for Linux
Symptoms
-
The Mail menu for a domain is not available.
Or:
Mail tab exists, however, when clicking it, Plesk shows the following:
PLESK_WARN: Warning: Permission denied
-
Mail service cannot be enabled using CLI:
# plesk bin mail.exe --on example.com
An error occurred while turning mail service for domain on or off: unable to define mail domain service ID
exit status 1 -
An error like the following can be observed in Plesk:
PLESK_ERROR: PleskFatalException: domain is not set!
Or:
The following error is received in API response:
CONFIG_TEXT: <status>error</status>
<errcode>7002</errcode>
<errtext>Unable to turnOff mails</errtext> - The entry with the type
mail
is absent in thepsa
database for the domain:
On the healty server:
mysql> select * from domainservices where dom_id=(select id from domains where name='example.com');
+----+--------+-----------+--------+---------------+----------------+
| id | dom_id | type | status | parameters_id | ipCollectionId |
+----+--------+-----------+--------+---------------+----------------+
| 95 | 37 | maillists | 0 | 0 | 95 |
| 96 | 37 | mail | 0 | 176 | 96 |
| 97 | 37 | web | 0 | 0 | 97 |
+----+--------+-----------+--------+---------------+----------------+
3 rows in set (0.00 sec)
When the issue is present:
mysql> select * from domainservices where dom_id=(select id from domains where name='example.com');
+----+--------+-----------+--------+---------------+----------------+
| id | dom_id | type | status | parameters_id | ipCollectionId |
+----+--------+-----------+--------+---------------+----------------+
| 95 | 37 | maillists | 0 | 0 | 95 |
| 97 | 37 | web | 0 | 0 | 97 |
+----+--------+-----------+--------+---------------+----------------+
2 rows in set (0.00 sec)
Cause
This is Plesk bug with ID PPPM-7251 which is planned to be fixed in future product updates.
Resolution
Сheck the Enable mail management functions in Plesk option in Plesk > Tools & Settings > Mail > Mail Server Settings or try to activate mail service for the domain by command-line while logged in to the server via SSH (for Linux OS) or RDP (for Windows OS) as follows:
For Linux:
# /usr/local/psa/bin/mail --update-service example.comd -status enabled -ignore-nonexistent-options
# /usr/local/psa/bin/mail --on example.com -ignore-nonexistent-options
# /usr/local/psa/bin/domain --info example.com | grep 'Mail service'
Mail service: On
For Windows:
"%plesk_dir%\bin\domain" --update example.com -mail_service true
"%plesk_dir%\bin\domain" --info example.com | findstr /C:"Mail service"
Mail service: On
If this did not help, use the steps below:
Automatic recovery for Linux:
-
Download this script for Linux.
# wget https://support.plesk.com/hc/article_attachments/115004385649/mail_restore_lin.zip
# unzip mail_restore_lin.zip -
Make it executable:
# chmod +x ./mail_restore.sh
-
Run the script with a domain name as an argument:
# ./mail_restore.sh example.com
- To restore several domains, execute the command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -sNe "select d.name from domains d join DomainServices ds on d.id=ds.dom_id where dom_id not in (select dom_id from DomainServices where type='mail')" > domain_list.txt
And then run the script:# while read dname; do /root/mail_restore.sh $dname; done < domain_list.txt
Automatic recovery for Windows:
-
Download and unpack this script for Windows.
-
Run the script with a domain name as an argument in PowerShell:
.\mail_restore.ps1 example.com
Manual recovery for Linux and Windows:
-
Run the following queries, having replaced the domain name with a valid one:
mysql> SELECT @ID:=max(id)+1 FROM psa.Parameters;
+----------------+
| @ID:=max(id)+1 |
+----------------+
| 6 |
+----------------+
mysql> INSERT INTO psa.Parameters VALUES (@ID,'mailProviderInstanceId','');
mysql> INSERT INTO psa.Parameters VALUES (@ID,'mailProviderType','local');
mysql> INSERT INTO psa.Parameters VALUES (@ID,'mailProviderUid','local');
mysql> INSERT INTO psa.Parameters VALUES (@ID,'nonexist_mail','reject');
mysql> SELECT @IPID:=max(id)+1 FROM psa.IpCollections;
+------------------+
| @IPID:=max(id)+1 |
+------------------+
| 11 |
+------------------+
mysql> INSERT INTO psa.IpCollections VALUES (@IPID);
mysql> SELECT @DOMID:=d.id,@IP:=ip.ipAddressId
FROM psa.domains d JOIN psa.DomainServices ds ON d.id=ds.dom_id
JOIN psa.IpAddressesCollections ip ON ds.ipCollectionId=ip.ipCollectionId
WHERE d.name='example.com';
+--------------+---------------------+
| @DOMID:=d.id | @IP:=ip.ipAddressId |
+--------------+---------------------+
| 1 | 1 |
+--------------+---------------------+
mysql> INSERT INTO psa.IpAddressesCollections VALUES (@IPID, @IP);
mysql> INSERT INTO psa.DomainServices (dom_id,type,status,parameters_id,ipCollectionId) values (@DOMID,'mail',0,@ID,@IPID);Note: replace
example.com
in the query to the corresponding domain name.
Comments
0 comments
Please sign in to leave a comment.