You can use the access lookup table to reject or allow messages from a list of defined senders. This table is evaluated by the smtpd daemon for all incoming messages. To activate this table, make sure the line smtpd_sender_restrictions = hash:/etc/postfix/access is included in main.cf. Then in the /etc/postfix/access file, specify a list of mail addresses. For each mail address, define an action. The mail addresses are in the first column, and the possible actions are in the second column. You can specify the e-mail addresses as patterns. You can refer to an actual e-mail address ([email protected]) but also to complete or partial IP addresses or domain names. The possible actions are as follows:
nnn message: This rejects the e-mail with a numerical code as defined in RFC 821, followed by the text message specified here.
Note RFC 821 defines the SMTP specifications. It includes a list of error codes that make clear why a connection failed. For example, there is the error message 500, "Syntax error, command unrecognized." Using these error codes makes troubleshooting easier. For the complete text of the RFC, see http://www.ietf.org/rfc/ rfc0821.txt.
REJECT: The e-mail is rejected with a generic error message. OK: The message is accepted.
DISCARD: The message is discarded, and no information is sent to the sender.
Listing 16-2 shows some examples of the content of the access lookup table. Note that if a host, network, domain name, and so on, is not specifically mentioned in this file, it is allowed access.
Listing 16-2. Example of the Access Lookup Table mydomain.co OK
[email protected] 550 No Spam allowed on this server
Was this article helpful?