Restricting users cannot send mail to off-site Domains


Problem 
 Restricting users cannot send mail to off-site Domains

Solution
 # cd /etc/postfix/ 
Create The File 
1.   local_domains  => edit the file your Domain Name

new.com   OK

2.   senders_user =>  edit the file
restricted Users Name this users cannot send mail to off-site Domains
fl@new.com          local_only
amit@new.com          local_only
##############################
####################

# vim /etc/postfix/main.cf
smtpd_restriction_classes = local_only
local_only =
   check_recipient_access hash:/etc/postfix/local_
domains, reject
smtpd_recipient_restrictions =
        check_sender_access hash:/etc/postfix/senders_
user,
        permit_mynetworks,
        reject_unauth_destination,
        permit


# postmap hash:/etc/postfix/local_domains
# postmap hash:/etc/postfix/sender_user
# /etc/init.d/postfix restart

Testing 

[raju@a]# telnet localhost 25  ====>  fl@new.com Not send Other Domains
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 a.raju.com ESMTP Postfix
HELO raju
250 a.raju.com
Mail From:<fl@new.com>
250 2.1.0 Ok
RCPT TO:<abc@gmail.com>
554 5.7.1 <fl@new.com>: Sender address rejected: Access denied
^]
telnet> q
Connection closed.

[raju@a]#  telnet localhost 25 ====> rajiv@new.com  send Other Domains
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 a.raju.com ESMTP Postfix
HELO raju
250 a.raju.com
Mail From:<rajiv@new.com>
250 2.1.0 Ok
RCPT TO:<abc@gmail.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
sdfsdfs
sdafsdaf.
.
telnet> q
Connection closed.

[raju@a]# telnet localhost 25  ===> fl@new.com send only Local  Domains
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 a.raju.com ESMTP Postfix
HELO raju
250 a.raju.com
MAil From:<fl@new.com>
250 2.1.0 Ok
RCPT TO:<rajiv@new.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
sdfsaf
asdsafsaf
.

Comments

Popular posts from this blog

How to install and configure node js and PM2 in rhel7

PCS Corosync Pacemaker Cluster Mariadb using NFS

How to Create or Configure iSCSI Server and Clinet