Postfix mail server configuration with mail sending restriction

Scenario : –

1)  Configure a local mail server in postfix
2)  Configure fetch mail to download mails from remote server
3) Apply sender restrictions to normal employees. They can send mails to adminlogs.info only.
4) Allow management members to send and receive mails globally .

#### Postfix conf for mail restrictions

message_size_limit = 20601572
mailbox_size_limit = 0
transport_maps = hash:/etc/postfix/transport
relayhost = mail.adminlogs.info:587
virtual_mailbox_limit_override = yes
virtual_mailbox_limit_maps = hash:/etc/postfix/vquota
smtpd_restriction_classes = allowed_only
allowed_only = check_recipient_access hash:/etc/postfix/allowed_domains, reject
smtpd_recipient_restrictions =
check_sender_access hash:/etc/postfix/restricted_senders
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
check_relay_domains
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

##### Sasl password settings. (created in  Remote server)
$ cat /etc/postfix/sasl_passwd
mail.adminlogs.info  [email protected]:password

#####Allowed domains setting , it will allow restricted senders to send mails to adminlogs.info
cat /etc/postfix/allowed_domains
adminlogs.info   OK

#####Restricted senders

$ /etc/postfix/restricted_senders

[email protected] allowed_only

#####Fetchmail scrip to download mails from remote mail server

poll remoteserverip with protocol pop3:
no dns, aka adminlogs.info
auth any
user [email protected] is * here  ( Should create this id in remote server  )
limit 25000
fetchlimit  51
password pass2
smtphost localhost

###### To send mails to global e-mail id’s for restricted senders

$ vi transport

[email protected] smtp:remoteserver ip:587

$ postmap transport

$  postfix reload

I have spent hours to setup this for a  production company and at last i completed the project successfully 🙂