Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a local development server (centos) which I develop a number of websites on. Occasionally I need to test email sending scripts.

I want to avoid the development server from sending emails to anyone who doesn't have an email address with a particular domain (ie:,, etc). So, I would like to create a white list or rule on the server which prevents emails being sent to any email address that doesn't match

I'm currently using PHP's built-in mail() function. But I imagine this is something more on the server level and I would like something that will manage ANY emails sent out from the server from any program/app/script/etc.

I can confirm that PHP is using /usr/sbin/sendmail.sendmail

share|improve this question

PHP mail() function sends messages according to MTA set as sendmail_path value in php.ini, by default, it's set to following:

sendmail_path = /usr/sbin/sendmail -t -i

on some systems it's a symlink to the binary of MTA, in my case it's sendmail-compatible binary of postfix MTA package, in other case it might be sendmail or qmail or whatever you use:

[root@giomacdesk ~]# ll /usr/sbin/sendmail
lrwxrwxrwx. 1 root root 21 ივლ  3 11:33 /usr/sbin/sendmail -> /etc/alternatives/mta
[root@giomacdesk ~]# ll /etc/alternatives/mta
lrwxrwxrwx. 1 root root 26 ივლ  3 11:33 /etc/alternatives/mta -> /usr/sbin/sendmail.postfix

So, according to this you can:

A. change sendmail_path to your custom script, write parser and filter messages accordingly. This will affect only outgoing messages sent via PHP mail() where sendmail_path was changed.

B. change configuration of mail server - this will affect all messages sent via MTA of your server, to do this you must check what is your server and configure it accordingly

In case of postfix:

  1. add following to the /etc/postfix/ transport_maps = hash:/etc/postfix/transport_maps

  2. create file /etc/postfix/transport_maps with following content: :
     * discard:
  3. hash: run postmap /etc/postfix/transport_maps

  4. restart postfix

share|improve this answer
I can confirm that it's /usr/sbin/sendmail.sendmail – David Sep 17 '13 at 12:52
I'd make life easier - install postfix, remove sendmail, enable postfix: yum install postfix -y;yum remove sendmail;chkconfig postfix on;service postfix start – GioMac Sep 17 '13 at 12:55

here is how I managed to do it. In Sendmail, you need to modify the mailertable. Add the following:
.   error:

This will essentially send any emails to and error for anything else.

share|improve this answer
Have you considered using "catchall" local mailbox in default mailertable route? . local:catchall – Andrzej A. Filip Sep 17 '13 at 14:27

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.