Find orphan nginx/Apache configs left by Plesk

comm -23 <(for i in /etc/nginx/plesk.conf.d/webmails/*.conf; do basename "${i%_*}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/nginx/plesk.conf.d/vhosts/*.conf; do basename "${i::-5}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/nginx/plesk.conf.d/ip_default/*.conf; do basename "${i::-5}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/nginx/plesk.conf.d/forwarding/*.conf; do basename "${i%_*}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/apache2/plesk.conf.d/webmails/*.conf; do basename "${i%_*}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/apache2/plesk.conf.d/vhosts/*.conf; do basename "${i::-5}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/apache2/plesk.conf.d/ip_default/*.conf; do basename "${i::-5}"; done | sort) <(plesk bin site -l | idn | sort)
comm -23 <(for i in /etc/apache2/plesk.conf.d/forwarding/*.conf; do basename "${i%_*}"; done | sort) <(plesk bin site -l | idn | sort)

Testing mail using cURL

List messages in the INBOX over IMAP(S):

curl -k -v --url 'imaps://mail.example.com:993' --user 'admin@example.com:setup' --request "EXAMINE INBOX"

Send a message over SMTP+STARTTLS:

curl -k -v --url 'smtp://mail.example.com:25' --user 'admin@example.com:setup' --ssl-reqd --mail-from 'admin@example.com' --mail-rcpt 'admin@example.org' --upload-file message

Retrieve unused IP addresses in Plesk via CLI

Retrieve a list of domains and their IP addresses:

plesk db "SELECT d.name, IF(ip.public_ip_address IS NULL, ip.IP_Address, ip.public_ip_address) AS 'IP' FROM domains d JOIN DomainServices ds ON d.id=ds.dom_id JOIN IpAddressesCollections ipc USING(ipCollectionId) JOIN IP_Addresses ip ON ipc.ipAddressId=ip.id WHERE ds.type='web';"

Retrieve unused IP addresses in Plesk via CLI:

plesk bin ipmanage -l | awk '{ if ($4 == 0 && $5 == 0) { print } }'

Run Plesk API request from CLI

curl -kLi -H "Content-Type: text/xml" -H "HTTP_AUTH_LOGIN: admin" -H "HTTP_AUTH_PASSWD:verysecurepwd" -H "HTTP_PRETTY_PRINT: TRUE" -d @payload.xml https://plesk.example.com:8443/enterprise/control/agent.php
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$request = New-Object System.Net.WebClient
$request.Headers.add('HTTP_AUTH_LOGIN','admin')
$request.Headers.add('HTTP_AUTH_PASSWD','verysecurepwd')
$request.Headers.add('HTTP_PRETTY_PRINT','true')
$response = $request.UploadFile('https://plesk.example.com:8443/enterprise/control/agent.php','.\payload.xml')
[System.Text.Encoding]::ASCII.GetString($response)