In my company we're using Postfix as a relay for Google Apps SMTP server in a Debian server. Legacy machines like scanners forward messages to our relay server.

How can i allow the scanner to only send mails through the relay only to certain domains (e.g. our .com)?

I'm pretty sure there's something here but I haven't found something working.


| improve this question | | | | |

How can i allow the scanner to only send mails through the relay ...

Check this --> How to set up an SMTP Relay Server

... only to certain domains

Check this --> Is it possible to limit outgoing emails in Postfix to one specific domain?

| improve this answer | | | | |
  • I need to combine the two suggestions but at the same time allow other machines to relay to everyone. Something like: if (sender==scanner) allow relay only to ourdomain.com else allow relay to everyone – mix Jul 1 '16 at 6:36

You can use postfwd to restrict the domains a specific IP address can send email to (regardless of relay):

action=REJECT; client_address=; recipient_domain!~/dom1\.com|dom2\.com/

Easy installation on Ubutu server is as follows:

$ apt install postfwd
$ vi /etc/postfix/main.cf
  smtpd_recipient_restrictions = check_policy_service inet:
$ vi /etc/postfix/postfwd.cf
  action=REJECT; client_address=; recipient_domain!~/dom1\.com|dom2\.com/
$ systemctl restart postfwd postfix
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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