Integrations · Mail servers and panels
Check outgoing recipients on CyberPanel
CyberPanel's mail server is Postfix, so our Postfix policy service checks the recipients of the mail your CyberPanel users send, while it is being submitted. This guide gives the CyberPanel paths, ports and settings for it. By default it only logs each result; refusing is yours to turn on. When a check cannot be made in time, the API answers with an error or the service is not running, Postfix carries on and the mail goes out as usual.
There is no CyberPanel plugin: you install the same files as on any Postfix server, from ev-policy-1.0.0.zip (MIT licence), and add its line to the two places CyberPanel sets recipient checks. It has not been tried on a real CyberPanel server yet: the paths below come from the Postfix configuration CyberPanel's installer writes, so try it on a test server first.
What you need
- A CyberPanel server you are root on, with its mail server installed, Postfix 3.0 or later (
postconf mail_version) and Python 3. - An API key from the API keys page with the permission Validate addresses, made for this server, with a daily credit cap. One key for the whole server.
Set it up
Unpack the zip on the server, then follow steps 2 and 3 of the Postfix guide: the key in
/etc/ev-policy/api-key(read without showing it),ev_policy.pyandev-policy.confin place, and the systemd socket enabled. The defaults fit CyberPanel: itsqueue_directoryis/var/spool/postfix, where the service's socket goes, andoutbound_networks(127.0.0.0/8 ::1/128) covers the sites on the server that hand mail to Postfix on localhost.List your mail domains. CyberPanel keeps the domains it receives mail for in its database (
virtual_mailbox_domains = proxy:mysql:…), which the service cannot read. In/etc/ev-policy/ev-policy.conf, setlocal_domainstopostfixfollowed by every domain listed under Email in CyberPanel, for examplelocal_domains = postfix example.com example.net. Mail to those domains is then never checked. Reject mode refuses to start without that list, and in log mode an unlisted domain's mailboxes would be checked as outside recipients and cost credits. Add each new mail domain there, then runsystemctl restart ev-policy.service.Port 25. CyberPanel's
/etc/postfix/main.cfhassmtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination. Put the check first, above what is there:smtpd_recipient_restrictions = check_policy_service { unix:private/ev-policy, timeout=5s, default_action=DUNNO, try_limit=1 } permit_mynetworks, permit_sasl_authenticated, reject_unauth_destinationPorts 587 and 465. Your users' mail programs log in on
submission(587) andsmtps(465), and CyberPanel's/etc/postfix/master.cfgives each of them its own list,-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject, so the line inmain.cfdoes not reach them. Add a named list tomain.cf:ev_submission_recipient_restrictions = check_policy_service { unix:private/ev-policy, timeout=5s, default_action=DUNNO, try_limit=1 } permit_sasl_authenticated rejectand in
master.cf, in both thesubmissionand thesmtpsentries, replace that-oline with:-o smtpd_recipient_restrictions=$ev_submission_recipient_restrictionsRun
postfix check, thenpostfix reload, and try a test address without sending a message:swaks --auth … --quit-after RCPTagainst port 587 ends the session afterRCPT TO, so the check runs and nothing is sent.journalctl -u ev-policyshows its log line.
Test addresses on sandbox.email-validation.org return the result their name says, cost nothing and contact no mail server. Never send a whole message to one: the bounce would hurt your server's sender reputation.
Modes, costs and privacy
Everything else is the Postfix service as it is: log mode by default, reject mode for the statuses you choose (never a recipient that could not be checked), its own cache, a limit per sender and per day, and only the outside recipient's address sent to the API. See modes, what it costs and privacy. For EU data residency, set region = eu.
CyberPanel's own features
- Email Limits, when you turn it on, adds CyberPanel's own policy check to
smtpd_data_restrictions, a different stage of the session. The two work side by side: neither replaces the other's line. - Upgrades. CyberPanel's upgrade script copies
/etc/postfix/aside before it reinstalls Postfix and copies it back afterwards, so your lines stay. After an upgrade, check them withpostconf smtpd_recipient_restrictionsandpostconf -M submission/inet smtps/inet.
Roll back
To switch checks off at once, run systemctl stop ev-policy.socket ev-policy.service: Postfix carries on by itself (default_action=DUNNO). To remove it, take the check out of smtpd_recipient_restrictions, put the two -o lines in master.cf back to -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject, delete ev_submission_recipient_restrictions, run postfix check and postfix reload, then systemctl disable --now ev-policy.socket.