Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I host several live sites, and several staging sites on one server that's running Ubuntu 14.04. Most of the sites are wordpress sites, and are using the php mail() function or the PHPMailer class to send their mail.

What I'd like to do is to prevent certain sites being staged from sending email. Maybe even whitelist the few live domains so that they are the only ones allowed to generate emails.

Is there a quick way to lock down the domains allowed to send mail?

share|improve this question
up vote 3 down vote accepted

Try putting this in the php.ini of the Vhost which you want to restrict:

disable_functions = mail,exec,shell_exec,passthru,system,proc_open,popen
share|improve this answer

Are the hosted domains connecting to a remote or local MTA?

If it's local, it can be configured for whitelisting by allowing relay just to specific hosts (which you should already be using to prevent you mail server from becoming a spam source).

If remote, just add a default iptables outgoing rule that bans access to remote port 25 and insert the allowed sources before this denying rule.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.