Restricting emails to particular domain name

Hello,

I need to restrict the mails going from any codes to a particular domain.

For example - No mail from any code should go to any email address with domain as abc.com - example - xyz@abc.com

Do we have any way to do it?

Thanks

You want only a single domain to be allowed when email is sent running on the unix box?

Assuming you are using sendmail --
sendmail is sometimes painful to deal with it has a configuration file, Eric Allman wrote a book on how to configure sendmail. Bryan Costales rewrote the 4th ed:

sendmail, 4th Edition: Bryan Costales, Claus Assmann, George Jansen, Gregory Neil Shapiro: 9780596510299: Amazon.com: Books

Alternatively consider doing this since you have only one.
Put an entry in /etc/hosts to redirect abc.com to localhost ( or to any other machine you want). The email will end up in the ~/dead.letter file for the user running the code.

This will block any email originating on the UNIX box from going to abc.com

Hi Jim,

Thanks for the reply.

The actual requirement is to restrict the mails going to production users from
Non production server.

If the code is running in production server, then the mail should go to where it is intended, but if the code is running in non production environment then the mail should not go the intended email address. It should not go either or if we can direct it to one particular mail box.

Email aliasing is what I tried to use, but what about the new email addresses coming tomorrow. Everytime I need to alias them. That's why I thought to restrict the domain.