I have been using postfix for sending emails , lets say i have a domain configured as mail.com now if i send email with from address as test@mail.com it is working fine
However if i try to send email as test@nomail.com ( 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/main.cf 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
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.
I understand i am doing lot of speculations my self thank you again for some thoughts on the matter, my postfix main.cf 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 test@nomail.com: Recipient address rejected: Domain not found.
Please check the message recipient “test@nomail.com” and try again.
my settings are:
Restrictions on sender addresses:
reject_non_fqdn_sender reject_unknown_sender_domain permit_mynetworks
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
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.