Postfix is normally installed by default, but just in case it isn't, you can install it with:
yum install postfix mailx -y
mailx is useful to test that you have configured Postfix correctly. You will need to open port 25 for Postfix to work properly, like this:
iptables -I INPUT -p tcp --dport 25 -j ACCEPT; service iptables save
There only appears to be a single SELinux setting related to Postfix, and it seems to be switched on by default:
allow_postfix_local_write_mail_spool --> on
Make sure that Postfix will run when the server reboots and start the service:
chkconfig postfix on
service postfix start
Finally, if you want to prevent users from sending emails, you could add the following directive to the Postfix config file:
smtpd_recipient_restrictions =
check_sender_access hash:/etc/postfix/restricted_senders
You can now add any users you want to prevent from sending email by adding them to this file like this:
testuser@dev.com reject
The usual suspects covered let's get back to the objective. You'll need to edit the postfix configuration file (
/etc/postfix/main.cf) and make sure you set and uncomment the following settings:
myhostname = redhat.dev.com
mydomain = dev.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
You can now restart postfix and test your configuration remotely, see this
post for details.
I think you've mixed it up a bit with the user restrictions. From your text above:
ReplyDeletesmtpd_recipient_restrictions = check_sender_access ...
I think it should be (to block senders):
smtpd_sender_restrictions = check_sender_access ...
Or (to block recipients):
smtpd_recipient_restrictions = check_recipient_access ...
My bad... you actually can...
ReplyDeleteI was just testing and I can block both senders and recipients in the following way:
smtpd_recipient_restrictions =
check_recipient_address hash:/etc/postfix/restr_rcpt_to
check_sender_address hash:/etc/postfix/restr_mail_from
reject_unauth_destination