If I have a list of trusted email servers, is it possible to configure my sendmail server to accept emails only from the trusted severs? How do I do that?
-
What is your definition of "accept emails"? Do you want to deny an connection at all from untrusted sources? Or prevent unauthorized servers from relaying through sendmail to third party domains?– Mike BFeb 13, 2015 at 23:15
-
@MikeB I think both are okay, because what I want is that emails from untrusted sources are not stored in the mailboxes in my server.– npcodeFeb 14, 2015 at 11:51
Add a comment
|
1 Answer
The simplest is to set up a firewall and only open TCP port 25 for the servers on your list.
The sendmail native way would be for instance to use /etc/mail/access
:
# by default we allow relaying from localhost...
localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY
# Allow Connect from trusted server IPs
Connect:10.9.8.7 OK
Connect:192.168.1.2 OK
# Since Sendmail does not support CIDR expansion list all ranges explicitly
# block 1.0.0.0/8 :
Connect:1 REJECT
# block 2.0.0.0/8 :
Connect:2 REJECT
Connect:3 REJECT
...
Connect:254 REJECT
Alternatively, set up your own DNS blacklist/whitelist.