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

  1. 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.py and ev-policy.conf in place, and the systemd socket enabled. The defaults fit CyberPanel: its queue_directory is /var/spool/postfix, where the service's socket goes, and outbound_networks (127.0.0.0/8 ::1/128) covers the sites on the server that hand mail to Postfix on localhost.

  2. 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, set local_domains to postfix followed by every domain listed under Email in CyberPanel, for example local_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 run systemctl restart ev-policy.service.

  3. Port 25. CyberPanel's /etc/postfix/main.cf has smtpd_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_destination
  4. Ports 587 and 465. Your users' mail programs log in on submission (587) and smtps (465), and CyberPanel's /etc/postfix/master.cf gives each of them its own list, -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject, so the line in main.cf does not reach them. Add a named list to main.cf:

    ev_submission_recipient_restrictions =
        check_policy_service { unix:private/ev-policy, timeout=5s, default_action=DUNNO, try_limit=1 }
        permit_sasl_authenticated
        reject

    and in master.cf, in both the submission and the smtps entries, replace that -o line with:

      -o smtpd_recipient_restrictions=$ev_submission_recipient_restrictions
  5. Run postfix check, then postfix reload, and try a test address without sending a message: swaks --auth … --quit-after RCPT against port 587 ends the session after RCPT TO, so the check runs and nothing is sent. journalctl -u ev-policy shows 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 with postconf smtpd_recipient_restrictions and postconf -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.

More on CyberPanel

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us