Restrict from email address for sending mails postfix

I have been using postfix for sending emails , lets say i have a domain configured as now if i send email with from address as it is working fine

However if i try to send email as ( i.e. with a domain that is not even present ) it is also sent. How can I restrict postfix to send only mails from domains which are present in virtualmin

Try popping
smtpd_reject_unlisted_sender = yes
into your /etc/postfix/ on a line of its own, restart postfix, and see how you go. I’ve not needed it myself, but the documentation points to this being the solution. When you test it, try doing it from an IP address that isn’t listed in my_networks as I suspect they will be permitted regardless.

Thank you for the answers, i tried it but the problem is i have to apply restriction for my system where postfix is installed since email client is being used from same ip. I believe that is the reason that putting smtpd_reject_unlisted_sender = yes did not work.

Is there any other solution which works for both same ip and non same ip`s

Like I said, I haven’t had to use this so I’m speculating.

Comment out or remove the line above.

You probably have something like the following in

smtpd_sender_restrictions = permit_mynetworks,

The permit_mynetworks is the first choice and postfix just finds the first match and stops processing. So, you could rearrange it and try using something like this.

smtpd_sender_restrictions = reject_unlisted_sender,

I understand i am doing lot of speculations my self thank you again for some thoughts on the matter, my postfix does not seem to contain the lines you mentioned.

However i added these lines and tested but i am afraid it does not seem to work as well. Is there any way to intercept this from log and then stopping postfix to forward message like any third party application for this?

I tested on my server, I get the following message

An error occurred while sending mail. The mail server responded:
450 4.1.2 Recipient address rejected: Domain not found.
Please check the message recipient “” and try again.

my settings are:
Restrictions on sender addresses:
reject_non_fqdn_sender reject_unknown_sender_domain permit_mynetworks

Restrictions on recipient addresses:
reject_unauth_pipelining reject_non_fqdn_recipient reject_unknown_recipient_domain permit_mynetworks permit_sasl_authenticated reject_unknown_sender_domain reject_unauth_destination reject_non_fqdn_sender reject_rbl_client reject_rbl_client reject_rbl_client reject_unknown_reverse_client_hostname reject_unverified_recipient permit_mynetworks

I have many troubles with emails over the years, but I’m no expert in this area though ;o)

Thank you , but it didn`t work . I have tried all of the possible combinations of settings that i can find through documentation and from help of you peoples but it does not seems to be working

Is it possible that it could be realted to the version of postfix i am using , i have postfix 2.1 installed , or maybe postfix does not want to work with me :smile:

Operating system CentOS Linux 7.7.1908 Perl version 5.016003
Path to Perl /usr/bin/perl BIND version 9.11
Postfix version 2.10.1 Mail injection command /usr/lib/sendmail -t
Apache version 2.4.6 PHP versions 5.4.16, 7.2.24
Webalizer version 2.23-08 Logrotate version 3.8.6
MySQL version 5.5.64 ProFTPD version 1.35
SpamAssassin version 3.4.0 ClamAV version 0.102.2

Here’s my software versions. I used virtualmin install to this server not that long ago. I don’t edit files manually, I generally always use virtualmin/webmin interface to update.

I’m not sure how to resolve

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.